SSH整合步聚

SSH整合:

1.添加Hibernate支持
2.添加strut2
3.添加spring

//
4.修改web.xml
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:app.xml</param-value>
 </context-param>
 <!-- 监听服务器启动并加载配置文件 -->
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>
 <filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

5.配置app.xml
创建dataSource,创建sessionFactory
创建三层的依赖属性注入。

Dao层依赖要sessionFactory,所以Dao实现类要继承HibernateDaoSupport类,那么就可以
使用HibernateTemplete模板对象进行数据的存取。

struts.xml配置action时,将class的值改成spring配置的action类的id

你可能感兴趣的:(SSH整合步聚)