要求spring mvc jsp页面只返回json内容
controller中添加
@Controller
@RequestMapping(“/cateTree”)
public class CateTreeController {
@Autowired
private CateTreeService cateTreeService;
@ResponseBody
@RequestMapping(value = "/cateTree",produces = "text/html;charset=UTF-8")
public String CateTree(HttpServletRequest request,Model model){
// int id=Integer.parseInt(request.getParameter("id"));
// List<CateTree> cateTreeList=cateTreeService.getCateChildByParentId( id);
List<CateTree> cateTreeList=cateTreeService.getCateChild();
return JSONArray.toJSONString(cateTreeList);
// return "productTypeList";
}
如图: