Servlet.init() for servlet [spring-dispatcher] threw exception

关于在测试SSM项目的时候报错Servlet.init() for servlet [spring-dispatcher] threw exception的解决办法

javax.servlet.ServletException: Servlet.init() for servlet [spring-dispatcher] threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol ConnectionHandler.process(AbstractProtocol.java:790)org.apache.tomcat.util.net.NioEndpoint C o n n e c t i o n H a n d l e r . p r o c e s s ( A b s t r a c t P r o t o c o l . j a v a : 790 ) o r g . a p a c h e . t o m c a t . u t i l . n e t . N i o E n d p o i n t SocketProcessor.doRun(NioEndpoint.java:1459)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor Worker.run(ThreadPoolExecutor.java:617)org.apache.tomcat.util.threads.TaskThread W o r k e r . r u n ( T h r e a d P o o l E x e c u t o r . j a v a : 617 ) o r g . a p a c h e . t o m c a t . u t i l . t h r e a d s . T a s k T h r e a d WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:748)

1,你肯定是在写完controller层之后开始出问题,而且在此之前你的这个SSM项目和前端的 还没有衔接好,所以你可以先把配置前端控制器的那部分先给注解掉,先不配置前端控制器,也就是下面这段代码

<servlet>
        <servlet-name>dispatcherServletservlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
        <init-param>
            <param-name>contextConfigLocationparam-name>
            <param-value>classpath:spring/*.xmlparam-value>
        init-param>

    servlet>
    <servlet-mapping>
        <servlet-name>dispatcherServletservlet-name>
        <!–先配置成*.do告诉spring容器只对.do结尾的请求进行拦截转发–>
        <!–因为涉及到前后端之间的地址传递,考虑使用/拦截所有的URL地址–>
        <!–如果是使用*.do不会存在静态资源无法访问的问题
            但是在使用拦截所有URL地址之后会出现静态资源无法加载(被拦截)
        –>
        <!–<url-pattern>/url-pattern>–>
        <url-pattern>/url-pattern>
    servlet-mapping>

2,要么就是你把前端的静态资源代码先不要放到WEB-INF下面,直接放到WEB-INF外面的目录下

3,再或者就是你把整个三层controller,service,dao层完全做好,和前台的衔接也做好,就能解决问题了

你可能感兴趣的:(WHAT,FUCKING,BUG)