struts1和spring主要使用以下两种方法加载applicatonContext:
1.在sturts-config.xml 中加载:
然后在web.xml里面需要配置一个Spring的监听器
2.在web.xml中加载:
然后将struts 交由spring控制,也就是覆盖Struts1中的DelegationRequestProcess,在struts-config.xml中加入:
1.在sturts-config.xml 中加载:
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB
-INF/applicationContext.xml" />
</plug-in>
然后在web.xml里面需要配置一个Spring的监听器
<listener>
<listener-
class>org.springframework.web.context.ContextLoaderListener</listener
-class>
</listener>
2.在web.xml中加载:
<context-param>
<param-name>contextConfigLocation</param-name>
<!--如果applicationContext.xml放classes目录下则写成classpath:applicationContext.xml-->
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servletclass>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
然后将struts 交由spring控制,也就是覆盖Struts1中的DelegationRequestProcess,在struts-config.xml中加入:
<controller
processorClass="org.springframework.web.struts.DelegatingRequestProces
sor">