【问题标题】:java.lang.IllegalArgumentException: The servlets named [X] and [Y] are both mapped to the url-pattern [/CreationClient] which is not permitted [duplicate]java.lang.IllegalArgumentException:名为 [X] 和 [Y] 的 servlet 都映射到不允许的 url 模式 [/CreationClient] [重复]
【发布时间】:2014-01-22 09:47:45
【问题描述】:

我无法启动 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

问题可能出在我的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>

谁能告诉我怎么了?

【问题讨论】:

  • 英语先生,你会说吗?
  • 抱歉@user3161023,虽然Stack Overflow (in French) 正在通过Area 51 审批流程,但在创建该站点之前,Stack Overflow 上的问题和解答预计将用英语。
  • 是的,我会说一点......

标签: eclipse tomcat


【解决方案1】:

尝试从com.sdz.tp.servlets.CreationClient 类中删除@WebServlet 注释。 servlet 映射可以在web.xml 中定义,也可以使用注解定义,但不能同时使用。

【讨论】:

  • 谢谢。我试过了,但现在我有一个错误 404!
  • 那么这是一个不同的问题。我建议你问一个新的细节问题,例如您正在调用哪个 URL。
  • 请问如何加入我的项目的 zip 文件?
  • 你不能。您应该在问题文本中包含对问题重要的代码部分。另见sscce.org
  • +1 表示对的人 :)
猜你喜欢
  • 1970-01-01
  • 2016-03-07
  • 2013-04-22
  • 1970-01-01
  • 2016-04-28
  • 2019-12-14
  • 2016-11-26
相关资源
最近更新 更多