zl程序教程

您现在的位置是:首页 >  前端

当前栏目

easyui tree在struts1中的使用详解编程语言

EasyUI编程语言 使用 详解 Tree
2023-06-13 09:20:42 时间
而struts1需要在action中进行json转换 JSONArray jsonArray = JSONArray.fromObject(treeNode);  

简单介绍下步骤,因为已经写过一篇struts2与easyui的使用,都差不多,可以参考  easyui struts后台实现tree返回json数据 .
一、在jsp页面引入easyui.css,jquery-1.8.0.min.js,jquery.easyui.min.js,easyui-lang-zh_CN.js,包括图片

 ul id="trueULid" /ul //用于展现tree

$(function() { 

 $(#trueULid).tree({ 

 url : shuiwujiguan_list.do?actionType=LoadTreeNode, 

 onSelect : function(node) { 

 window.opener.document.getElementById("swjg").value = node.text; 

 window.opener.document.getElementsByName("swjg_dmSelect")[0].value = node.id; 

 onBeforeExpand : function(node,param){ 

 $(#trueULid).tree(options).url = "shuiwujiguan_list.do?actionType=LoadTreeNode id=" + node.id; 

 }); 

});
如果没其他业务需求,可不要onSelect ,onBeforeExpand 
response.setContentType("application/json;charset=UTF-8"); 

PrintWriter out = response.getWriter(); 

JSONArray jsonArray = JSONArray.fromObject(treeNode); 

out.write(jsonArray.toString()); 

out.flush(); 

out.close(); 

四、添加jar包
可能不同的项目环境会有所不同,也以至于查找了N多资料,下载了N多jar包,在csdn上花费了N多积分 

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/14523.html

cjava