前台代码:
var setting = {
data: {
simpleData: {
enable: true,
idKey: “id”,
pIdKey: “pid”,
rootPId: 0
}
},
callback: {
onClick: yonghuzTreeOnClick
}
};
$.post(“<%=request.getContextPath()%>/product/findZtree.action”,{id:1},function(obj){
$.fn.zTree.init($(“#prouser_tree”), setting, obj).expandAll(true);
},”json”);
后台代码:
@RequestMapping(“findZtree.action”)
@ResponseBody
public List<Dept> findZtree(){
System.out.println(“进来了”);
List<Dept> list =productService.findZtree();
for (Dept dept : list) {
System.out.println(dept);
}
return list;
}
经测试,后台不能接收前台的请求?为何会这样?
var setting = {
data: {
simpleData: {
enable: true,
idKey: “id”,
pIdKey: “pid”,
rootPId: 0
}
},
callback: {
onClick: yonghuzTreeOnClick
}
};
$.post(“<%=request.getContextPath()%>/product/findZtree.action”,{id:1},function(obj){
$.fn.zTree.init($(“#prouser_tree”), setting, obj).expandAll(true);
},”json”);
后台代码:
@RequestMapping(“findZtree.action”)
@ResponseBody
public List<Dept> findZtree(){
System.out.println(“进来了”);
List<Dept> list =productService.findZtree();
for (Dept dept : list) {
System.out.println(dept);
}
return list;
}
经测试,后台不能接收前台的请求?为何会这样?
解决方案
70
直接访问<%=request.getContextPath()%>/product/findZtree.action这个路径~先看看能不能进入你的后台~可能是路径错了!
20
<%=request.getContextPath()%> 这个错了 你可以打出来看看这是什么
应该是
<%
String path = request.getContextPath();
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%>
url填这个试试
<%=basePath%>product/findZtree.action
应该是
<%
String path = request.getContextPath();
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%>
url填这个试试
<%=basePath%>product/findZtree.action
10