SSH三层框架中的事务处理 大家讨论下平常在开发中,SSH三层框架中的事务处理(策略 || 策略+实例)。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我一直用一个办法Spring配置文件头部改为:<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.0.xsd">配置内容中加上:<!-- aop事务 --> <!-- 建立事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <!-- 定义事务通知 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <!-- 对查找方法进行只读事务通知要求查找方法以find开头 可按需要修改 --> <tx:method name="find*" propagation="SUPPORTS" read-only="true" /> <!-- 对其它方法如 增 删 改进行事务支持 --> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <!-- 切面定义 --> <aop:config> <!-- 对cn.qdqn.biz包及子包中的任意方法进行切面 --> <aop:pointcut id="bizMethods" expression="execution(* cn.qdqn.swap.biz..*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" /> </aop:config>over. 有人用过fileUpLoad上传东西的吗? 新手请教关于过滤器的问题 问一个用struts2专业结构来解决超链接<a>传值的问题 问一个关于struts2传递对象的问题!!! 关于Maven sun portal 能否在 tomcat 上部署? 用sax解析xml的问题?? 这个错误捕捉不到 关于webligoc控制台下的ejb的几个问题 jboss-3.0.4_tomcat-4.1.12的问题 使用json让String和Map之间转换 北京:JAVA高级工程师
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">配置内容中加上:<!-- aop事务 -->
<!-- 建立事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!-- 定义事务通知 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 对查找方法进行只读事务通知要求查找方法以find开头 可按需要修改 -->
<tx:method name="find*" propagation="SUPPORTS" read-only="true" />
<!-- 对其它方法如 增 删 改进行事务支持 -->
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- 切面定义 -->
<aop:config>
<!-- 对cn.qdqn.biz包及子包中的任意方法进行切面 -->
<aop:pointcut id="bizMethods"
expression="execution(* cn.qdqn.swap.biz..*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />
</aop:config>
over.