报错信息:
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
org.springframework.web.struts.DelegatingActionUtils.findRequiredWebApplicationContext(DelegatingActionUtils.java:148)
org.springframework.web.struts.DelegatingRequestProcessor.initWebApplicationContext(DelegatingRequestProcessor.java:134)
org.springframework.web.struts.DelegatingRequestProcessor.init(DelegatingRequestProcessor.java:114)
org.apache.struts.action.ActionServlet.getRequestProcessor(ActionServlet.java:602)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
解决办法:
1、:发现原来它的配置文件不是放在WEB-INF下,而是放在src目录下,解决的方法:
1)将其spring的配置文件applicationContext转移阵地,转到WEB-INF下;
2)在web.xml下加入如下语句:
<!-- Spring ApplicationContext配置文件的路径,可使用通配符,多个路径用,号分隔此参数用于后面的Spring-Context loader -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml,classpath*:applicationContext*.xml</param-value>
</context-param>
2、再在web.xml里面加上这些
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>