3

当我尝试运行我的项目时出现错误

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

我的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>
4

2 回答 2

14

条目的必须<servlet-name>与条目的<servlet-mapping>完全相同。<servlet-name><servlet>

因此,在您的具体情况下,更改<servlet-mapping>条目中的这一行

<servlet-name>dispatcher</servlet-name>

<servlet-name>DispatcherServlet</servlet-name>
于 2015-12-30T06:29:49.467 回答
0

正如文中所写

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

<servlet>和中的 servlet 名称<servlet-mapping>必须相同。

于 2015-12-30T06:35:56.390 回答