当我尝试运行我的项目时,我收到错误
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>
答案 0 :(得分:10)
<servlet-name>
条目的<servlet-mapping>
必须与<servlet-name>
条目的<servlet>
完全相同。
因此,在您的具体情况下,请在<servlet-mapping>
条目
<servlet-name>dispatcher</servlet-name>
到
<servlet-name>DispatcherServlet</servlet-name>
答案 1 :(得分:0)
如
所述Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name dispatcher
<servlet>
和<servlet-mapping>
中的servlet名称必须相同。