<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <!-- ======================事务管理器========================= --> <bean name="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- ==============================事务工厂============================== --> <bean name="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionManager" ref="transactionManager"></property> <property name="transactionAttributes"> <props> <prop key="insert*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean>
action中添加spring插件,action引用对象改成代理类
<action
attribute="userForm"
input="/form/user.jsp"
name="userForm"
parameter="task"
path="/user"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy" />
</action-mappings>
<message-resources parameter="com.fxzutils.struts.ApplicationResources" />
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/classes/applicationContext*.xml" />
</plug-in>
本文介绍了一个使用Spring框架进行事务管理的具体配置案例,包括Hibernate Session工厂的设置、事务管理器及事务代理工厂的定义,并展示了如何在Struts2中集成Spring。
1万+

被折叠的 条评论
为什么被折叠?



