$("#tree").jstree(
{
"json_data":{
"ajax": {
url : "/rest/columnjson/createTreeJson",
data : function (n) {
alert(n);
return {
"operation": "get_children",
"id": n.attr ? n.attr("id").replace("node_", ""):1
};
}
}
},
"plugins": ["themes","json_data", "ui","crrm","contextmenu", "search"],
})现在是能够读取到后台数据,并已拼接成json字符串,但是jsp页面无法显示后台数据,弹出的n值为-1,望哪位大神指点一下,谢谢。
@ResponseBody
public void createTreeJson(HttpServletRequest request, HttpServletResponse response)
throws SecurityException, IOException{ request.setCharacterEncoding("utf-8");
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
StringBuilder json = basicColumnService.createTreeNode();
json.deleteCharAt(json.length() - 1); out.print("[" + json + "]");
out.flush();
out.close();
}