整合的原则:谁能先测试,先写谁
1、持久化类、映射文件
2、引入SessionFactory
3、dao层和servic层
4、写spring的声明式事务处理
5、写action和前台
步骤:
1、创建一个web project
2、把该工程的编码形式改成utf-8
3、把jsp的编码形式也改成utf-8
4、导入包:struts2、hibernate、spring、数据库驱动包
5、创建三个source folder
src:存放源代码
config:存放配置文件 spring、hibernate、struts
test:存放测试类
6、创建持久化类和映射文件
7、写spring的配置文件
config/spring/
applicationContext.xml
applicationContext-db.xml
8、在test中创建一个包com.pure.s2sh.test
9、在上面的包中创建一个类SessionFactoryTest、SpringUtil
10、创建dao层和service层的类和接口
11、写spring的声明式事务处理的配置和把dao层和service层所有的累放入到spring容器中
12、进行测试声明式事务处理
13、创建一个action
14、把action放入到spring容器中去
<bean id="personAction" class="com.action.PersonAction" scope="prototype">
<property name="personService">
<ref bean="personService"/>
</property>
</bean>
//注意事项:scope="prototype"必须写
15、测试action的创建
16、写Struts2的配置文件
17、写web.xml文件