Struts+Hibernate+Spring整合

一:在web.xml文件中的配置
<!—文本参数 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext*.xml</param-value>
</context-param>

<!-- 监听器 在Sprint web Libraries包下,sprint-web.jar下,contxt包中 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- 过滤器 在Sprint web Libraries包下,sprint-web.jar下,filter包中 -->

<filter>
<filter-name>econdingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>

<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>econdingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>

<!—延迟加载过滤器 在Spring Persistence包下,spring-orm.jar中,hibernate3.support文件包中-->
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
二:在Struts-config-xml中的配置
<!—控制器 在Sprint web Libraries包下 ,sprint-struts.jar下,strurs包中-->
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
</controller>

三:在applicationContext.xml中的配置

<!—事物 在spring Persistence包下,spring-Hibernate包下,orm.hibenate包里-->
<bean
id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="find" read-only="true"/>
<tx:method name="search" read-only="true"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>

<aop:config>
<aop:advisor advice-ref="txAdvice"
pointcut="execution(* com.svse.service.*Service.*(..))"/>
</aop:config>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值