Spring整和struts

本文详细介绍如何在Struts框架中整合Spring框架,包括在web.xml中不注册Spring内容,通过Struts配置文件引入Spring配置,并使用DelegatingActionProxy进行Action的全权委托。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Struts与Spring整和:
1.web.xml里面不需要注册spring框架的内容。
2.需要在struts的配置文件里面做两部
第一步:将spring 的配置文件路径作为插件注册struts配置文件里面。

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
 <set-property property="contextConfigLocation"
     value="/WEB-INF/applicationContext.xml" />
  </plug-in> 
第二步:用org.springframework.web.struts.DelegatingActionProxy类截获Action的生成的动作,
 <action
      attribute="loginForm"
      input="/login.jsp"
      name="loginForm"
      path="/login"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy" />

然后将action交给application.xml里面。交给spring去做。
<beans>
<bean id="dao" class="dao.CustomerDao">

</bean>
<!-- 将dao 装进LoginAction里面
bean里面的name要和struts配置文件的action标签的path一致
相当于将action的生成完全交给spring去做
这种方法叫做全权委托(用得最广)
 -->
<bean name="/login" class="prj23_1.action.LoginAction">
<property name="dao">
<ref local="dao"/>
</property>
</bean>
</beans>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值