eclipse java.lang.IllegalArgumentException:名为 [X] 和 [Y] 的 servlet 都映射到不允许的 url-pattern [/CreationClient]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20925423/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.IllegalArgumentException: The servlets named [X] and [Y] are both mapped to the url-pattern [/CreationClient] which is not permitted
提问by user3161023
I can not start Tomcat: Server Tomcat v7.0 Server at localhost failed to start.
我无法启动 Tomcat: Server Tomcat v7.0 Server at localhost failed to start。
Caused by: java.lang.IllegalArgumentException: The servlets named [CreationClient] and [com.sdz.tp.servlets.CreationClient] are both mapped to the url-pattern [/CreationClient] which is not permitted
at org.apache.catalina.deploy.WebXml.addServletMapping(WebXml.java:335)
at org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet(ContextConfig.java:2466)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2148)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2109)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2102)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2102)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2102)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2102)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1293)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 7 more
4 janv. 2014 19:57:38 org.apache.catalina.core.ContainerBase startInternal
The problem is probably with my web.xml
:
问题可能出在我的web.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>tp1</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>CreationClient</servlet-name>
<servlet-class>com.sdz.tp.servlets.CreationClient</servlet-class>
</servlet>
<servlet>
<servlet-name>CreationCommande</servlet-name>
<servlet-class>com.sdz.tp.servlets.CreationCommande</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CreationClient</servlet-name>
<url-pattern>/CreationClient</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CreationCommande</servlet-name>
<url-pattern>/CreationCommande</url-pattern>
</servlet-mapping>
</web-app>
Could someone tell me what's wrong?
有人能告诉我出了什么问题吗?
回答by David Levesque
Try removing the @WebServlet
annotation from class com.sdz.tp.servlets.CreationClient
. The servlet mapping can be defined either in web.xml
or using an annotation, but not both.
尝试@WebServlet
从 class 中删除注释com.sdz.tp.servlets.CreationClient
。servlet 映射可以在web.xml
注释中定义或使用注释定义,但不能同时定义。