简体   繁体   中英

java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name

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>

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM