后台

@RequestMapping(value = "getAllChildByRId", method = RequestMethod.GET)
public ModelAndView getAllChildByRId(String rId, Model model) {
XLog.showLogInfo("rId = " + rId);
ModelAndView modelAndView = new ModelAndView();
try {
List<ChildAndPropertyAndContent> list = mainService.getChildAndPropertyAndContent(rId);
XLog.showLogInfo("list = " + list);
modelAndView.addObject("rId", rId);
modelAndView.addObject("list", list);
modelAndView.addObject("childSize", list.size());
/*if (list.size() == 0)
modelAndView.setViewName("/index");
else*/
modelAndView.setViewName("/main");
} catch (Exception e) {
modelAndView.addObject("error", e.getMessage());
modelAndView.setViewName("/main");
e.printStackTrace();
}
XLog.showLogInfo("modelAndView.getViewName()" + modelAndView.getViewName());
return modelAndView;
}

前台:

$.ajax({
type: "GET",
url: "<%=basePath%>main/getAllChildByRId?rId=" + id + "",
async: false,
dataType: "text",
success: function (data) {
window.location.href = data;
/*if ("${childSize}" > 0) {
} else {
layer.msg("该节点下没有节点");
}*/
},
error: function () {

}
});

前台接收不到数据主要是dataType没有设置正确,同时应该减产ajax请求类型是否和后台一致