使用spring 的action-servlet.xml解决struts线程问题
2009-10-11 15:27
639 查看
使用spring 的action-servlet.xml解决struts线程问题
<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>
<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 的action-servlet.xml解决struts线程问题
- 解决spring+struts 找不到Action问题
- 整合Spring+Hibernate+Struts时抛Servlet action is not available异常解决
- Struts集成Spring出错:Servlet action is not available 的解决
- Struts集成Spring出错:Servlet action is not available 的解决
- There is no Action mapped:关于struts2.5解决通配符无法使用问题
- SpringBank 开发日志 重新设计Action调用Service的参数传递 使用泛型解决类型转换问题
- 在struts.xml文件中使用spring代理,管理action
- 解决了Hibernate+Spring+Struts架构使用OpenSessionInView的问题
- 解决乱码问题的最佳解决方式(struts struts2 jsp servlet action等)
- struts多模块开发中使用SwitchAction出错的问题解决
- Struts集成Spring出错:Servlet action is not available 的解决
- cxf、struts、spring中web.xml过滤url问题解决方案
- Spring MVC 使用问题与解决--HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
- Struts集成Spring出错:Servlet action is not available 的解决
- Struts集成Spring出错:Servlet action is not available 的解决
- struts.xml中的default-action-ref解决不能解析网址问题
- spring 使用一般接口 返回数据null 的问题 解决
- 代码详解の使用CountDownLatch解决面试问题:T1和T2线程执行计算,T3线程计算结果的统计
- Hibernate数据的lazy问题,以及使用spring整合hibernate lazy的解决办法(好文转载)