第一步:导入Struts和Spring 的集成所需的驱动包:struts2-spring-plugin-2.1.8.1.jar
第二步:导入hibernate,不需要在hibernate中创建sessionFactory
第三步:导入Spring,在applicationContext.xml中:
a、配置声明式事务
b、配置事务管理器
c、配置事务传播特性
d、配置那些类的哪些方法需要织入事务
第四步:通过Hibernate自动创建Pojo和dao,注意创建dao时dao是由spring注入的方式创建好的
第五步:导入struts2.0
a、导入所需要的驱动包;
b、在web.xml中如下配置过滤器:
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
c、在dao目录下创建struts.xml,在里面配置路径、页面以及action之间的关系
d、在web.xml中配置如下信息
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
第二步:导入hibernate,不需要在hibernate中创建sessionFactory
第三步:导入Spring,在applicationContext.xml中:
a、配置声明式事务
b、配置事务管理器
c、配置事务传播特性
d、配置那些类的哪些方法需要织入事务
第四步:通过Hibernate自动创建Pojo和dao,注意创建dao时dao是由spring注入的方式创建好的
第五步:导入struts2.0
a、导入所需要的驱动包;
b、在web.xml中如下配置过滤器:
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
c、在dao目录下创建struts.xml,在里面配置路径、页面以及action之间的关系
d、在web.xml中配置如下信息
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货