使用 DelegatingActionProxy
2017-04-26 17:47
183 查看
本篇文章主要介绍了"使用 DelegatingActionProxy",主要涉及到使用 DelegatingActionProxy方面的内容,对于使用 DelegatingActionProxy感兴趣的同学可以参考一下。
先使用一个问题简单讲一下:
<action
attribute="loginForm"
input="/login.jsp"
name="loginForm"
path="/login"
scope="req
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="error" path="/error.html" />
<forward name="success" path="/success.html" />
</action>
<!--name 的取值一定要和Struts 配置文件action 中的path 的值相对应-->
<bean name="/login" class="cn.qdqn.ssh.struts.action.LoginAction">
<property name="userBO">
<ref bean="userBO"/>
</property>
</bean>
先使用一个问题简单讲一下:
Spring 中如何通过DelegatingActionProxy整合struts
需要先在 web.xml中 配置listener 然后在 struts-config.xml 中修改action中的type 为 org.springframework.web.struts.DelegatingActionProxy 还要加个 <plug-in> 然后在 Spring的配置文件中配置对应的bean
【最佳方案】使用
DelegatingActionProxy将Struts Action 管理全权委托给Spring 框架Action 的创建和对象的依赖注入全部由IOC容器来完成,使用Spring的DelegatingAcionProxy来帮实现代理的工作.DelegatingActiongProxy继承于org.apache.struts.action.Action 。此时需要将struts- config.xml中所有Action类别全部配置为
org.springframework.web.struts.DelegatingActionProxy:
<action
attribute="loginForm"
input="/login.jsp"
name="loginForm"
path="/login"
scope="req
4000
uest"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="error" path="/error.html" />
<forward name="success" path="/success.html" />
</action>
3,4两种方式都需要在WEB-INF下新建一个action-servlet.xml作为Spring context文件,创建Struts Action Bean,并对Action进行BO或DAO Bean注入:
<!--name 的取值一定要和Struts 配置文件action 中的path 的值相对应-->
<bean name="/login" class="cn.qdqn.ssh.struts.action.LoginAction">
<property name="userBO">
<ref bean="userBO"/>
</property>
</bean>
结论:
以上2种方式实现了由Spring管理Struts的Action,从而可以利用Spring在Struts Action中轻松的注入BO或DAO,还可以将 Spring 的 AOP 拦截器应用于Struts 动作,用最小的代价处理横切关注点。
第3种整合方式只需要配置一个<controller>,不需要改动Struts Action配置信息,但Struts的 RequestProcessor只能被重载一次,如果在应用中还要进行编码等其它功能RequestProcessor重载时,此种方式将异常繁琐。
相关文章推荐
- structs中使用 DelegatingActionProxy
- 使用 DelegatingActionProxy
- 使用 DelegatingActionProxy
- spring2.5 怎么没有spring2.0中的org.springframework.web.struts.DelegatingActionProxy ?
- org.springframework.web.struts.DelegatingActionProxy
- DelegatingFilterProxy的原理及使用
- 关于spring的DelegatingActionProxy
- 使用DelegatingFilterProxy有什么好处
- DelegatingFilterProxy未指定targetBeanName默认使用拦截器名称
- spring2.5中没有org.springframework.web.struts.DelegatingActionProxy
- filter中的DelegatingFilterProxy使用事例
- DelegatingFilterProxy(委派过滤器代理类)使用
- SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-005-定义切面使用@Aspect、@EnableAspectJAutoProxy、<aop:aspectj-autoproxy>
- springAOP报java.lang.NoSuchMethodException: $Proxy和使用AOP后action采用autoware注入值为null
- SPRING IN ACTION 第4版笔记-第九章Securing web applications-001-SpringSecurity简介(DelegatingFilterProxy、AbstractSecurityWebApplicationInitializer、WebSecurityConfigurerAdapter、@EnableWebSecurity、@EnableWebMvcS)
- DelegatingFilterProxy的原理及使用
- DelegatingFilterProxy的原理及使用
- DelegatingActionProxy
- java开源框架集成常见错误之spring2.5中没有org.springframework.web.struts.DelegatingActionProxy ,使得Action不能注入到spring中
- 配置DelegatingFilterProxy使用Spring管理filter chain