一个基于EXT实现的树,先上图。 动态加载加右键菜单。 希望拿到可以跑起来看看效果的,需要按以下步骤做。 1 安装oracle,这个例子只做了oracle版本,如果需要,后期可以加上mysql版本,呵呵。 2 运行建用户及表空间的脚本。db_desc_ddl.sql. 3 执行初始化数据脚本。db_desc_dml.sql 4 导入工程,部署,打开浏览器输入 http://127.0.0.1:8080/desc 就可以看到效果了。 关于该实例的一些说明。 这个实例基于spring+struts+ibatis,外加js lib ext 3.3.1. 发挥连接作用的就是这个/WEB-INF/web.xml文件了。贴内容。 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>page/index.jsp</welcome-file> </welcome-file-list> <!-- web应用启动时初始化applicationContext --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <description>spring初始配置</description> <param-name>contextConfigLocation</param-name> <param-value>classpath:conf/spring/application.xml</param-value> </context-param> <!-- 配置struts过滤应用请求 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> <init-param> <description>struts2初始配置文件</description> <param-name>config</param-name> <param-value>conf/struts/struts.xml</param-value> </init-param> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> 可以看到配置中,通过过滤器配置将struts引入。同时通过listener将spring引入。这样顺藤摸瓜,思路就相当清晰了。当一个web请求进来以后,比如http://127.0.0.1:8080/desc,肯定会通过这个配置去找到主页文件的位置page/index.jsp,进入主页后, var treeLoader = new Ext.ux.tree.XmlTreeLoader( { dataUrl : '/desc/getDesc.action' }); var rootnode = new Ext.tree.AsyncTreeNode( { text : '投诉分类', id:"0", leaf:'false' }); EXT通过/desc/getDesc.action 这个请求找到id为0的结点来渲染出自己的根节点,本例中设置了自动展开根节点, tree.on('expandnode', function(node) { /* 展开时获取父节点 */ parent_node = node; }); 所以打开index.jsp页面时,你会发现根节点及根节点下一层都是展开的。/desc/getDesc.action 如何找到自己的数据源呢。它进入web.xml,发现自己需要经历struts2这个过滤器,于是在这个过滤器里,应用把工作交给了struts,在struts配置中找到getDesc这个控制器, <action name="getDesc" class="DescAction" method="getDesc"> <result name="xmlMessage" type="plaintext"></result> </action> 在struts内部,这个请求交给了getDesc方法来处理,getDesc方法返回来一个XML串。 <?xml version="1.0" encoding="UTF-8"?><nodes><node id="40" text="咨询" /><node id="20" text="建议" /><node id="10" text="投诉" /><node id="50" text="预约" /><node id="30" text="报障" /><node id="1090464" text="集团自查工单修改" /><node id="1093809" text="明天" /><node id="1062780" text="业务支撑内部工单" leaf="true" /></nodes> index.jsp获得这个串,在将它渲染到页面上treecontainer这个层(div)中。 知道了这个过程,你就知道应该去怎么配置spring和struts以及ibatis了。 -------------------------------------------------- 顺便说下,log4j日志环境的搭建。很简单。 1 导入 commons-logging-1.1.jar log4j-1.2.14.jar 2 写log4j.properties 3 在代码中使用方式 static Log log = LogFactory.getLog("Action类"); log.debug("result is " + result);












































































































- 1
- 2
- 3
- 4
- 5
- 6
- 10

- zjmachao2013-06-02对初学者,一个非常有用的实例
- sghi7172013-04-27调试运行了,效果还行,马马虎虎。
- xiangrikui20052013-02-25怎么运行起来没有树的效果?
- asose2012-09-11初学者一个不错的示例,学习了。
- dusaiya2011-10-25例子还是写的不错的,就是希望注释再多一点。毕竟新手,学起来不那么容易。
- 粉丝: 6
- 资源: 14

我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
