用到ContextLoaderPlugIn没有?在struts-config.xml中定义的ContextLoaderPlugIn应只载入struts action bean的spring配置文件。在web.xml中的ContextLoaderServlet则载入其它的spring配置文件其原因是ContextLoaderPlugIn和ContextLoaderServlet会以不同的key去存放各自实例化的WebXmlApplicationContext,但OpenSessionInViewFilter取得是ContextLoaderServlet实例化的。

解决方案 »

  1.   

    用到了ContextLoaderPlugIn
    我把所有的 action 都独立出来放在 applicationContext_action.xml
    里面了而在 web.xml 里面也只配置了 applicationContext.xml
      

  2.   

    其实是DAO没有管理事务造成的,并不是OpenSessionInView的问题再注意:
    在struts.action.advinfo.PostAction中的infoClassesDAO并没有进行事务管理
    <property name="infoClassesDAO">
    <ref bean="InfoClassesDAO" /> ====>> 改为DAOProxy再试试
    </property>通过代理调用dao,spring才会给你管理事务
      

  3.   

    回:laoxing521(想做程序员的农民)改了成后
    错误:
    org.springframework.beans.factory.FactoryBeanNotInitializedException: Error creating bean with name 'DAOProxy': FactoryBean returned null object: probably not fully initialized (maybe due to circular bean reference)
      

  4.   

    <bean id="DAOProxy" 
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref local="transactionManager" />
    </property>
    <property name="target">
    <list>  ==> 删掉
    <ref local="InfoClassesDAO" />
    </list>  ==> 删掉
    </property>.....
    </bean>
      

  5.   

    laoxing521(想做程序员的农民) 我现在事务配置成功了,可还是那个
    FlushMode.NEVER没有变成 FlushMode.AUTO
      

  6.   

    原来DAO层没有实现接口,事务根本就没有作用到SESSION