问题
When I try run my project I get error
Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name dispatcher
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3156)
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3135)
at org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1372)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1176)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:771)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
My web.xml
:
<servlet>
<servlet-name>DispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
回答1:
The <servlet-name>
of the <servlet-mapping>
entry must be exactly the same as the <servlet-name>
of the <servlet>
entry.
So, in your specific case, change this line in <servlet-mapping>
entry
<servlet-name>dispatcher</servlet-name>
to
<servlet-name>DispatcherServlet</servlet-name>
回答2:
As written in the
Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name dispatcher
Your servlet name in the <servlet>
and <servlet-mapping>
must be same.
来源:https://stackoverflow.com/questions/34524081/java-lang-illegalargumentexception-servlet-mapping-specifies-an-unknown-servlet