在Struts+Spring+Ibatis配置时的一个错误
javax.servlet.ServletException: No WebApplicationContext found: no ContextLoaderListener registered ? org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java: 545 ) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java: 486 ) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java: 274 ) org.apache.struts.action.ActionServlet.process(ActionServlet.java: 1482 ) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java: 525 ) javax.servlet.http.HttpServlet.service(HttpServlet.java: 709 ) javax.servlet.http.HttpServlet.service(HttpServlet.java: 802 )
![]()
root cause
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered ? org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java: 84 ) org.springframework.web.struts.DelegatingActionUtils.findRequiredWebApplicationContext(DelegatingActionUtils.java: 122 ) org.springframework.web.struts.DelegatingActionProxy.getWebApplicationContext(DelegatingActionProxy.java: 139 ) org.springframework.web.struts.DelegatingActionProxy.getDelegateAction(DelegatingActionProxy.java: 120 ) org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java: 105 ) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java: 484 ) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java: 274 ) org.apache.struts.action.ActionServlet.process(ActionServlet.java: 1482 ) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java: 525 ) javax.servlet.http.HttpServlet.service(HttpServlet.java: 709 ) javax.servlet.http.HttpServlet.service(HttpServlet.java: 802 )
![]()
问题的解决:
在web.xml 文件中加
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>