zoukankan      html  css  js  c++  java
  • easyui tree在struts1中的使用

    前段时间写过类似的功能,开发环境是struts2,jdk1.6,tomcat
    而这次是修改N年前的项目
    项目的开发环境为struts1,jdk1.4,weblogic8,比较过时所以就增加了使用easyui的难度。
    难点为:一、配置action  不能像struts2那样直接可以和json完美整合
    action中result结果集为
    <result type="json">
             <param name="root">treeNodes</param>
    </result>
    而struts1需要在action中进行json转换 JSONArray jsonArray = JSONArray.fromObject(treeNode);  
    二、jdk1.4无法使用泛型(不用也无妨)
    三、struts1与json整合,需要N个jar包(jar包冲突问题很头疼)

    简单介绍下步骤,因为已经写过一篇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 
    onBeforeExpand 是要在展开父节点之前把该ID传入,以查找它的子节点。

    二、struts1不需要配置json(因为配不了)

    三、action方法,这是和struts2不同的地方。
    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包
    json-lib-2.4-jdk14.jar
    commons-lang-2.0.jar
    commons-beanutils.jar
    commons-collections.jar
    commons-logging.jar
    ezmorph-1.0.6.jar

    可能不同的项目环境会有所不同,也以至于查找了N多资料,下载了N多jar包,在csdn上花费了N多积分 
    终于凑到可以一起正常使用的了。

    从CSDN上下载的那6个jar有一个损坏的(commons-lang.jar),所以又找了一个
    重新整合一下 供需要的朋友下载。地址:http://download.csdn.net/detail/itmyhome/6571713


  • 相关阅读:
    output中的path和publicPath
    CSS3 animation设置图片上下移动
    富文本编辑器UEditor
    日历插件:Bootstrap的datetimepicker插件
    文档流、浮动 、定位的概念【转】
    css position [转]
    css line-height [转]
    div 中 id 和 class使用详解【转】
    js中的require、define、export、import【转】
    js 立即调用函数 IIFE(Immediately Invoked Function Expression) 【转】
  • 原文地址:https://www.cnblogs.com/itmyhome/p/4131382.html
Copyright © 2011-2022 走看看