《Struts2+Spring3+Hibernate3 集成方法》.pdf
文本预览下载声明
Struts2+Spring3+Hibernate3集成
目 录
1. Struts2 集成 1
1.1. 把Struts 提供的jar 包拷贝到/WEB-INF/lib/ 目录下 1
1.2. 在web.xml 中配置Struts 的过滤器 2
2. Struts2 开发 2
2.1 编写Struts Action 程序,需要继承ActionSupport 2
2.2 创建struts.xml 的Action 映射文件 3
3. Struts2+Spring 集成 3
3.1 按第 1 步 “Struts2 集成”方法集成Struts2 3
3.2 再把Struts 的Spring 插件把拷贝到/WEB-INF/lib/ 目录下 3
3.3 把Spring 提供的jar 拷贝到/WEB-INF/lib/ 目录下 3
3.4 web.xml 配置Spring 的过滤器 3
3.5 创建applicationContext.xml 配置文件 4
4. Struts2+Spring+Hibernate 集成 5
4.1 先按照 “Struts2+Spring 集成”方法执行 5
4.2 导入Apache Commons 几个jar 包 5
4.3 导入Hibernate 几个jar 包 5
4.4 数据库的JDBC 驱动 5
4.5 在applicationContext.xml 中加入如下的配置 5
4.6 创建hibernate.cfg.xml 文件 6
5. Struts2+Spring+Hibernate 开发 6
5.1 编写Model 类 6
5.2 编写Model 类的HBM 映射文件 7
5.3 在applicationContext.xml 中指定HBM 映射文件路径 8
5.4 编写DAO 接口和实现类程序,并继承HibernateDaoSupport 8
5.5 在applicationContext.xml 中配置DAO Bean 10
6. 注意事项10
1. Struts2 集成
1.1. 把 Struts 提供的jar 包拷贝到/WEB-INF/lib/ 目录下
Struts 需要如下几个包:
解压:struts--lib.zip
需要:
struts2-core-.jar
xwork-core-.jar
ognl-3.0.1.jar
freemarker-2.3.16.jar
javassist -3.11.0.GA.jar
和所有以 “commons- ”开头的包。
其它包根据需要再导入,否则系统启动会出错。
1.2. 在web.xml 中配置Struts 的过滤器
web.xml 放在/WEB-INF/ 目录下。
?xml version= 1.0 encoding= UTF-8?
!DOCTYPE web-app PUBLIC
-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
/dtd/web-app_2_3.dtd
web-app
!-- Struts2 过滤器 --
filter
filter-namestruts2/filter-name
filter-classorg.apache.struts2.dispatcher.FilterDispatcher/fil
ter-class
/filter
filter-mapping
filter-nam
显示全部