level 4
你可以用异步请求返回数据,后台:
HttpServletResponse response = ServletActionContext.getResponse();
PrintWriter out = response.getWriter();
List<JSONObject> treeList = new ArrayList<JSONObject>();
......
out.println(JSONArray.fromObject(treeList).toString());
out.close();
前台:
$(function() {
$.ajax({
async : false,
type : "POST",
url : 'jsp/monthplan/querystatistic/depTree.action',
success : function(data) {
if (data != null)
$.fn.zTree.init($("#depTree"), setting, jQuery.parseJSON(data));
else
$.fn.zTree.init($("#depTree"), setting, jQuery.parseJSON(data));
}
});
});
2011年12月22日 01点12分