采用DelegatingRequestProcessor将处理转发给Spring容器中的bean
DelegatingRequestProcessor继承自RequestProcessor。为了让Struts使用elegatingRequestProcessor,还需要在struts-config.xml文件中增加如下代码:
struts-config.xml
<action-mappings>
<action
path="/regist"
name="registForm"
type="com.ssh.web.action.RegistAction"
validate="true"
scope="request"
input="/error.jsp" >
<forward name="regestr_success" path="/regestr_success.jsp" />
<forward name="regestr_error" path="/regestr_error.jsp" />
<forward name="login" path="/index.jsp" />
</action>
</action-mappings>
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />
这一行代码是告诉Struts用DelegatingRequestProcessor来代替原来的RequestProcessor。完成设置这个设置后,Struts会将拦截到的用户请求转发到Spring context下的bean,根据bean的name属性来匹配。而Struts中的action配置则无需配置type属性(即使配置了type属性也不起任何作用,除非在spring的配置文件里找不到对应的name属性值,除非这个条件直到今天才知道。记下来备忘:))。
配置了上面的一行代码后,就可以在Spring的配置文件(可以不是applicationContext.xml,比如假设这里是action-servlet.xml)中配置用来处理请求的Action bean了。配置的时候需要注意的是Action bean不再需要id属性,而要用name替代id属性,这时name属性的值应与struts-config.xml中配置的Action的path属性的值相同。
这样,处理请求的Action就能处于Spring的管理之下了。
applicationContext-action.xml
<bean name="/regist" class="com.ssh.web.action.RegistAction">
<property name="userService" ref="userServiceProxy" />
</bean>
分享到:
相关推荐
org.springframework.web.struts.DelegatingRequestProcessor.class org.springframework.web.struts.DelegatingTilesRequestProcessor.class org.springframework.web.struts.DispatchActionSupport.class org....
<set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor" /> 3,测试 1,写Action类与Service类 @Controller("testAction") @Scope("prototype...
上传的资料都是非常经典的,这也是我学习过程中的心得,希望大家能给我指点,也希望大家多上传资料共同学习。千万不要传空文件夹。。。
13.1.2. Spring Web MVC框架的特点 13.2. DispatcherServlet 13.3. 控制器 13.3.1. AbstractController 和 WebContentGenerator 13.3.2. 其它的简单控制器 13.3.3. MultiActionController 13.3.4. 命令控制器 13.4. ...
1.使用Spring 的 ActionSupport 2.使用Spring 的 DelegatingRequestProcessor 类。 3.全权委托。
用DelegatingRequestProcessor和DelegatingActionProxy两种方法实现struts和spring的整合,不同的地方就在struts-config.xml文件中,当前文件中DelegatingRequestProcessor是注释的。
1,使用Spring 的 ActionSupport 2, 使用Spring 的 DelegatingRequestProcessor 类。 3,全权委托。
Spring与struts整合主要有三种方式,通过Spring的ActionSupport类,通过Spring的DelegatingRequestProcessor类、通过Spring的DelegatingActionProxy类。
采用在web.xml中加载spring配置文件的方法降低struts和spring的耦合度,使用自定义的MyDelegatingRequestProcessor类来代替spring的DelegatingRequestProcessor类来解决spring中action的bean的重复配置问题。...
Spring 和 struts 整合的三种方式。 1,使用Spring 的 ActionSupport 2, 使用Spring 的 DelegatingRequestProcessor 类。 3,全权委托。
//第一种方式:使用 Spring 的 ActionSupport 类整合 Structs ...//第二种方式:使用 Spring 的 DelegatingRequestProcessor 覆盖 Struts 的 RequestProcessor //第三种方式:将 Struts Action 管理委托给 Spring 框架
DelegatingRequestProcessor DelegatingServletInputStream DelegatingServletOutputStream DelegatingThemeSource DelegatingTilesRequestProcessor DelegatingTimerListener DelegatingTimerTask ...
NULL 博文链接:https://qq421606162.iteye.com/blog/2000148
本系统使用 Spring 的DelegatingRequestProcessor 覆盖 Struts 的 RequestProcessor,将 Struts 动作整合到 Spring 框架中。 Spring框架是轻量级组件部署和运行的容器,可以很好的支持AOP(面向切面编程)的...
本系统使用 Spring 的DelegatingRequestProcessor 覆盖 Struts 的 RequestProcessor,将 Struts 动作整合到 Spring 框架中。 Spring框架是轻量级组件部署和运行的容器,可以很好的支持AOP(面向切面编程)的...
本系统使用 Spring 的DelegatingRequestProcessor 覆盖 Struts 的 RequestProcessor,将 Struts 动作整合到 Spring 框架中。 Spring框架是轻量级组件部署和运行的容器,可以很好的支持AOP(面向切面编程)的...
实例讲解spring整合struts的几种方式 1,使用Spring 的 ActionSupport 2, 使用Spring 的 DelegatingRequestProcessor 类。 3,全权委托。