错误:No WebApplicationContext found: no ContextLoaderListener or DispatcherServlet registered?

错误详情:

严重: Servlet.service() for servlet [jsp] in context with path [/exam-system-tab-shiro] threw exception
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener or DispatcherServlet registered?
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:253)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

报错的原因:未添加  <load-on-startup>1</load-on-startup>

 1 <!-- 配置spring代理shiro的过滤器 -->
 2     <filter>
 3         <filter-name>shiroFilterBean</filter-name>
 4         <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
 5         <!-- 让spring控制shiro过滤器的生命周期 -->
 6         <init-param>
 7             <param-name>targetFilterLifecycle</param-name>
 8             <param-value>true</param-value>
 9         </init-param>
10     </filter>
11     <filter-mapping>
12         <filter-name>shiroFilterBean</filter-name>
13         <url-pattern>/*</url-pattern>
14     </filter-mapping>
15     <!-- 配置攔截器,攔截所有的請求,讓一個方法對應一個請求 -->
16     <servlet>
17         <servlet-name>dispatcherServlet</servlet-name>
18         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
19         <!-- 指定配置類路徑 -->
20         <init-param>
21             <param-name>contextConfigLocation</param-name>
22             <param-value>cn.mgy.config</param-value>
23         </init-param>
24         <!-- 指定加載註解配置類的容器 -->
25         <init-param>
26             <param-name>contextClass</param-name>
27             <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
28         </init-param>
29         <load-on-startup>1</load-on-startup> 
30     </servlet>
31     <servlet-mapping>
32         <servlet-name>dispatcherServlet</servlet-name>
33         <url-pattern>/</url-pattern>
34     </servlet-mapping>

 

posted @ 2019-05-12 19:53  梦在原地  阅读(5914)  评论(0编辑  收藏  举报