关于Spring整合Struts采用监听器方式后,是否必须改写baseAction的问题.

    最近在javaeye看了很多Struts整合Spring的文章,之前虽然一直在使用SSH框架,但是在整合SSH框架方面,一直有个问题没有得到解决,那就是在采用以加载监听器方式整合的时候,为什么要在baseAction中写一个getBean方法.

===================================================================================
配置方案一: 这是我在工程中正在使用的一种方式,也是我最关心的一种方式
===================================================================================
1.在web.xml中加载监听器


<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>


2.在struts-config.xml中修改action的type类型为org.springframework.web.struts.DelegatingActionProxy
  使用委托方式,将struts中的Action配置到spring中,然后通过委托方式来调用Action

<action path="/mouldFront/mainPageManager" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy" parameter="method">
.......
<forward name="index" path="/mouldFront/index.jsp"/>
.......
</action>


3.在contextConfigLocation定义的配置文件中配置action需要的各种services

<bean name="/mouldFront/mainPageManager"
class="com.mould.web.front.actions.MainPageAction">
.......
<property name="infoService" ref="infoService"/>
.......
</bean>


4.在baseAction中添加getBean方法.

public Object getBean(String name) {
ApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(servlet.getServletContext());
return ctx.getBean(name);
}


我的疑惑是,既然已经使用了spring的IOC特性,在struts启动时ContextLoaderListener已经加载了上下文,而且我们已经将struts的action交给spring来管理,那我们为什么还要在baseaction中写这样的方法呢?我觉得这样做没有意义.不知道我理解对不对,希望能有熟悉的人来解释下.

这种整合方式不对,整合不需要BaseAction
在web.xml配置监听
在struts-config.xml里面配置

在applicationContext.xml里面配置