关注!我的理解是可把action不设置为单例,这样就可以避免在Struts Action中的线程问题

解决方案 »

  1.   

    The Struts action has no knowledge of Spring and could be used in non-Spring applications without changing a single line of code. It's not at the mercy of a change to the RequestProcessor, and it can take advantage of Spring's AOP features.The benefits of action delegation don't stop there, either. Once you have your Struts action under Spring's control, you can leverage Spring to give them more pizzazz. For example, without Spring, all Struts actions must be threadsafe. If you set the <bean> tag's singleton attribute to "false," however, your application will have a newly minted action object on every request. You might not need this feature, but it's nice to know you have it in your back pocket. You can also take advantage of Spring's lifecycle methods. For example, the <bean> tag's init-method attribute is used to run a method when the Struts action is instantiated. Similarly, the destroy-method attribute executes a method just before the bean is removed from the container. These methods are a great way to manage expensive objects in much the same way as the Servlet lifecycle does//from ibm
      

  2.   

    我的E文也不好,大概的意思就是说:
    Struts的Action不需要依赖Spring,而且脱离Spring运行不需要改一行代码,而且还可以利用Spring AOP的优点.
    还有就是Struts的Action是线程安全的,其实就增加了编程的难度,如果用SPRING管理Action,把singleton设为false,就是原形,每次请求SPRING都创建一个实例,你就不需要被线程困饶了,你还可以利用SPRING管理BEAN的生命周期,比如说初始化和销毁BEAN等等.