spring事务管理

[align=center][size=xx-large][color=red][b]spring管理事务提交[/b][/color][/size][/align]

[url]http://blog.csdn.net/huangbiao86/article/details/6588780[/url]


修改applicationContext.xml加入事务管理

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
">

<!-- 事务管理 -->
<!-- 定义一个事务管理器 -->
<bean id="myHibTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" >
</property>
</bean>
<!--定义事务通知-->
<tx:advice id="txAdvice" transaction-manager="myHibTransactionManager">
<!--声明事务规则-->
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<!--对其他方法要求只读事务-->
<tx:method name="*" propagation="SUPPORTS" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<!--定义一个切面,即定义哪些方法应用这些规则-->
<aop:pointcut id="bizMethods" expression="execution(* com.accp.ke.biz.*.*(..))"/>
<!--将事务通知和切面组合(织入)-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods"/>
</aop:config>


修改struts-config.xml配置文件,使用代理action类
type="org.springframework.web.struts.DelegatingActionProxy"

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="classpath:applicationContext.xml"/>
</plug-in>





参考:
1.[url]http://blog.csdn.net/qjyong/article/details/4824179[/url]
2.[url]http://www.blogjava.net/robbie/archive/2009/04/05/264003.html[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值