1. 建web项目:ssh
2. 引入spring包:Spring 3.0,放在lib文件夹下
3. 配置数据源,引入hibernate包:hibernate3.3, 放在lib文件夹下
数据源配置 选择第一个对勾里面选1和3 选择第二个对勾里面不选
4. 映射表。
改映射好表的序列
5. 自己编写dao,在spring配置
6. 测试spring和hibernate整合
7. 引入struts2包:struts2.1
8. 删除所有包,重新引入新的ssh包
9. 在web.xml文件引入spring配置
10. 编写action,在spring配置action
11. 配置struts.xml文件
9: 在web.xml中
<!--配置Spring核心监听器-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
10:
<!-- action交给spring,还需配置一个常量 -->
<constant name="struts.objectFactory"value="spring"></constant>
applicationContext.xml不在/WEB-INF/下的解决思路:
web.xml:
<!--1.放在src目录 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application*.xml</param-value>
</context-param>
<!--2.放在WEB-INF目录 -->
<!--<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/application*.xml</param-value>
</context-param>
-->