用spring容器来接管struts中的action

在Struts中加入Spring框架的时候,相信大家对

<action-mapping>
 <action input="/login.jsp" 
          name="loginActionForm"
          path="/loginAction" 
          scope="request"   
          type="org.springframework.web.struts.DelegatingActionProxy" 
          validate="false">
           <forward name="success" path="/success.jsp" />
           <forward name="failure" path="/failure.jsp" />
 </action>
</action-mapping>

这段代码 是再熟悉不过吧。不过每个Action都加这个东西。会不会觉得很累呢。有点。。现在好了。。有这个办法可以解决这个问题。

就是在struts-config.xml中的使用<contrlller>

 <controller>
 <set-property property="processorClass" value="org.springframework.web.struts.DelegationRequestProcessor"/>
</controller>

这样就可以把Struts的Action 交给Spring控制了。。
也不用在Action中写上type="org.springframework.web.struts.DelegatingActionProxy"  

最后的代码样式为:

<action-mapping>
 <action input="/login.jsp" 
          name="loginActionForm"
          path="/loginAction" 
          scope="request"   
          type="org.springframework.web.struts.DelegatingActionProxy" 
          validate="false">
           <forward name="success" path="/success.jsp" />
           <forward name="failure" path="/failure.jsp" />
 </action>
</action-mapping>

<controller>
 <set-property property="processorClass" value="org.springframework.web.struts.DelegationRequestProcessor"/>
</controller>

快去试试吧。。另外,要注意的在整合三大框架的时候,可能会出现因为三大框架中的某些个.jar包出现冲突,而引发一些问题,不过这些问题都可以通过相应的.jar包之间进行调整。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值