struts1 之 ContextLoader组件

[align=center][size=xx-large][color=red][b]把action交给spring管理
[/b][/color][/size][/align]

参考链接:
1.[url]http://www.blogjava.net/zJun/archive/2007/01/08/92417.html[/url]
2.[url]http://love398146779.iteye.com/blog/909723[/url]
3.[url]http://blog.sina.com.cn/s/blog_6848c4440100siua.html[/url]


[size=medium][b][color=red]一、spring和struts1.x[/color][/b][/size]

spring的一个jar包:[color=red]spring-webmvc-struts.jar[/color]

[color=red]<plug-in/>[/color]将struts的处理转给Spring了,由Spring IOC控制调用Struts中的组件,这样你就需要在Spring那个applicationContext.xml中加入Action相应的bean类

1.web.xml里配置struts-config.xml(struts1.x配置文件),Tomcat启动加载该文件。

<action name="treeForm" path="/tree" scope="request"
parameter="actions"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="select"
path="/platform/common/treeSelect.jsp" />
<forward name="defeat" path="/common/error.jsp" />
</action>

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/classes/spring/core/applicationContext-action.xml" />
</plug-in>
注意:此处的plug-in也可以注释掉,直接在applicationContext.xml里加载applicationContext-action.xml也可以


2.applicationContext-action.xml

<bean name="/frameTest" class="com.lenovo.example.web.action.FrameTestAction">
<property name="frameTestService" ref="frameTestService" />
</bean>

<bean name="/flowTest" class="com.lenovo.example.web.action.FlowTestAction">
<property name="flowTestService" ref="flowTestService" />
<property name="flowService" ref="engineflowService"/>
</bean>



[size=medium][b][color=red]二、spring和struts2.x[/color][/b][/size]

通过struts2.x里的一个jar包,启动自动将struts2.x控制权给spring
spring的一个jar包:[color=red]struts2-spring-plugin-2.1.8.1.jar[/color]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值