Spring 弹簧设置不工作
我不能让SpringWeb工作Spring 弹簧设置不工作,spring,jsp,web-applications,Spring,Jsp,Web Applications,我不能让SpringWeb工作 我的pom.xml依赖于SpringWeb和SpringWebMVC My web.xml有org.springframework.web.context.ContextLoaderListener applicationContext.xml定义bean“测试” My index.jsp尝试通过RequestContextIls.getWebApplicationContext(请求)获取上下文 但我得到了一个例外: java.lang.IllegalState
org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: No WebApplicationContext found: not in a DispatcherServlet request?
at org.springframework.web.servlet.support.RequestContextUtils.getWebApplicationContext(RequestContextUtils.java:83)
at org.springframework.web.servlet.support.RequestContextUtils.getWebApplicationContext(RequestContextUtils.java:60)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:65)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
这是我完整的web.xml
<?xml version="1.0"?>
<web-app version="3.0">
<listeners>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listeners>
</web-app>
org.springframework.web.context.ContextLoaderListener
webapplicationcontextils.getWebApplicationContext(应用程序)
而不是
requestContextILS.getWebApplicationContext(请求)
您是否在部署描述符中使用Springs
DispatcherServlet
?据我所知,从stacktrace可以看出,这表明您不是,这是让Spring在web环境中工作的一个重要部分。这是webmvc,对吗?我能摆脱webmvc而只使用spring web吗?你应该在你的web中定义和。xml…@Jaiwo99请阅读我的最后一条评论。会话bean和请求bean必须有第二个侦听器类RequestContextListener