S2SH开发之-整合篇1
整合步骤:
1.新建一个工程
2.把整个工程的编码改成utf-8格式
3.把整个jsp页面的编码也变成utf-8格式
4.导入需要的jar包到 WEB-INF 的lib目录中
- struts
- hibernate
-spring
-db
- junit
5.建立三个src folder
5.1 src 存放源代码
-domain
-dao
-impl
-service
-impl
-action
5.2 config 存放所有配置文件
-struts2
-hibernate
-spring
-applicationContext.xml
-applicationContext-db.xml
5.3 test 存放测试用例
6.在dao和service层相应的包中写接口和类
7.在applicationContext-db.xml文件中写sessionFactory
8.在test包中新建一个类SessionFactoryTest,目的是为了测试 SessionFactory是否配置正确
9.写spring的声明式事务处理
10.在spring的配置文件中写dao和service
11.通过savePerson方法测试声明式事务处理
12.编写action
13.编写struts2的配置文件
14.编写web.xml文件
14.1 web.xml配置
spring容器是以监听器的形式与tomcat整合的
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext.xml</param-value>
</context-param>
15.测试
本文转自arac 51CTO博客,原文链接:http://blog.51cto.com/skyarac/1288322,如需转载请自行联系原作者