最近在javaeye看了很多Struts整合Spring的文章,之前虽然一直在使用SSH框架,但是在整合SSH框架方面,一直有个问题没有得到解决,那就是在采用以加载监听器方式整合的时候,为什么要在baseAction中写一个getBean方法.
===================================================================================
配置方案一: 这是我在工程中正在使用的一种方式,也是我最关心的一种方式
===================================================================================
1.在web.xml中加载监听器
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<action path="/mouldFront/mainPageManager" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy" parameter="method">
.......
<forward name="index" path="/mouldFront/index.jsp"/>
.......
</action>
<bean name="/mouldFront/mainPageManager"
class="com.mould.web.front.actions.MainPageAction">
.......
<property name="infoService" ref="infoService"/>
.......
</bean>
public Object getBean(String name) {
ApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(servlet.getServletContext());
return ctx.getBean(name);
}
这种整合方式不对,整合不需要BaseAction
在web.xml配置监听
在struts-config.xml里面配置
在applicationContext.xml里面配置