用artClassActionProxy把原先的artClassAction包装一下,使得artClassAction的方法支持事务!<bean id="artClassActionProxy"
          class="org.springframework.transaction.interceptor.
                 TransactionProxyFactoryBean">
        <property name="transactionManager">
            <ref bean="transactionManager" />
        </property>
        <property name="proxyTargetClass">
            <value>true</value>
        </property>
        <property name="target">
            <ref local="artClassAction" />
        </property>
        <property name="transactionAttributes">
            <props>
                <prop key="*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>

解决方案 »

  1.   

    用BeanNameAutoProxyCreator 该怎么配置呢
      

  2.   

    你那样不行的呢。.我有很多ACTION的...你看下我的配置文件..应该怎么改事务回滚才有效啊我这样配置回滚不了..已经想了很多办法了..问题解决马上结帖
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
    <beans> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <!-- property name="defaultAutoCommit"><value>false</value></property-->
    </bean>
    <!--定义jdbc数据源的事务管理器 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
    </bean>

      <!-- 定义事务拦截器 --> 
       <bean id="transactionInterceptor" 
          class="org.springframework.transaction.interceptor.TransactionInterceptor"> 
          <!-- 事务管理器 --> 
          <property name="transactionManager" ref="transactionManager" /> 
          <!-- 事务传播属性 --> 
          <property name="transactionAttributes"> 
             <props> 
                <prop key="update*">PROPAGATION_REQUIRED,Exception</prop> 
             </props>
          </property> 
       </bean> 
     
     
      <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
      <!-- 下面定义BeanNameAutoProxyCreator所需要的事务拦截器 --> 
    <property name="interceptorNames">
    <list>
    <value>securityInterceptor</value>
    <value>transactionInterceptor</value>
    </list>
    </property>
    <!-- 指定对满足哪些bean name的bean自动生成业务代理 --> 
    <property name="beanNames">
    <list>
    <value>*Action</value>
    </list>
    </property>
    </bean>
    <bean  
            class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">  
            <property name="transactionInterceptor" ref="transactionInterceptor"/>  
        </bean>  


    <bean id="securityInterceptor" class="com.safetys.sqldao.Advice">
    </bean>
    <!-- SqlMap setup for iBATIS Database Layer -->
    <bean id="sqlMapClientFactoryBean" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    <property name="configLocation" value="WEB-INF/sql-map-config.xml"/>
    <property name="dataSource" ref="dataSource"/>
    </bean>   <!-- ========================= DAO DEFINITIONS: IBATIS IMPLEMENTATIONS ========================= -->
    <bean id="artClassAction" class="com.safetys.action.ArtClassAction" scope="prototype">
    <property name="sqldao" value="com.safetys.sqldao.ArtClassDao"></property>
    <property name="sqldao2" value="com.safetys.sqldao.TempDao"></property>
    <property name="service" value="com.safetys.service.ArtClassService"></property>
    </bean>
    <bean id="voteAction" class="com.safetys.action.VoteAction" scope="prototype">
    <property name="sqldao" value="com.safetys.sqldao.VoteDao"></property>
    <property name="service" value="com.safetys.service.VoteService"></property>
    </bean>
    <bean id="menuAction" class="com.safetys.action.MenuAction" scope="prototype">
    <property name="sqldao" value="com.safetys.sqldao.MenuDao"></property>
    <property name="service" value="com.safetys.service.MenuService"></property>
    </bean>
    <bean id="tempAction" class="com.safetys.action.TempAction" scope="prototype">
    <property name="sqldao" value="com.safetys.sqldao.TempDao"></property>
    <property name="service" value="com.safetys.service.TempService"></property>
    </bean>
    </beans>这里只列出部分