加载spring容器
让tomcate自动加载spring 在web.xml
集成方案 1 :
action代理对象:在原来的action配置中的原来action type属性改为:
org.springframework.web.struts. DelegatingActionProxy 其他不变 在spring配置文件中添加这个action的定义 形式如: <bean name=”/login” class=”真正的action类路径”
集成方案2:
在struts中注册spring插件
从一个可以获取spring 上下文的基类中派生出一个action,在派生类中使用super.XX()方法来获取spring中的bean
org.springframework.web.struts. ActionSupport是一个struts action的实现
他重载了getServlet()方法 从
ContextLoaderPlugin中获取webApplicationContext
集成方案3:使用请求委托.
为了使action委托看上去更为直观一些,Spring提供了DelegatingRequestProcessor,另一种专门用于Spring的请求处理器.需要在struts-config.xml中做如下配置:
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"/>
这样 ,DelegatingRequestProcessor 将告诉 Struts 自动将动作请求委托给 Spring 上下文中的 Action 来处理 . 这使得我们可以在 struts-config.xml 中用 struts action 的真正类型来声明它们 . 例如 :
<action type="真正action类" path="/list" >
当接受到一个针对/list的请求时,DelegatingRequestProcessor会自动从Spring上下文配置文件中查找一个名为/list 的Bean(实为一个Struts Action)类.