<bean name="/register" class="com.action.RegisterAction" singleton="false">
<property name="businessService">
     <ref bean="businessService"/>
   </property>
</bean>
RegisterAction是Action的实现类,businessService是业务逻辑,Spring把businessService注入到 Action中,在Action中只要写businessService的get和set方法就可以了,同时action的bean设为 singleton="false",这样每次新建一个实例,从而解决了Struts中Action的线程同步问题
1.struts 中实现接口
   <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
     <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml,/WEB-INF/action-servlet.xml" />
   </plug-in>
2.将<action type 变为
= "org.springframework.web.struts.DelegatingActionProxy"
3.编写action-servlet.xml 如:
   <bean name="/Analyse" class="com.apple.struts.action.IndexAnalyseAction" singleton="false">
     <property name="flowService">
       <ref bean="flowService"/>    //此处对应applicationContext.xml
     </property>
   </bean>
4.web.xml中配置
<filter>  
   <filter-name>hibernateFilter</filter-name>  
   <filter-class>  
      org.springframework.orm.hibernate3.support.OpenSessionInViewFilter   
   </filter-class>  
   <init-param> 
     <param-name>singleSession</param-name> 
     <param-value>true</param-value> 
   </init-param> 
</filter> 
<filter-mapping>  
   <filter-name>hibernateFilter</filter-name>  
   <url-pattern>/*</url-pattern>  
</filter-mapping>
                  
                  
                  
                  
本文介绍如何通过Spring解决Struts框架中Action的线程安全问题,包括配置上下文加载插件、修改Action类型、编写Spring配置文件及整合Hibernate会话管理。
          
      
          
                
                
                
                
              
                
                
                
                
                
              
                
                
              
            
                  
					194
					
被折叠的  条评论
		 为什么被折叠?
		 
		 
		
    
  
    
  
            


            