Eclipse IllegalArgumentException:名为[Hello]和[com.crunchify.jsp.servlet.HelloCrunchify]的servlet都映射到url模式

Eclipse IllegalArgumentException:名为[Hello]和[com.crunchify.jsp.servlet.HelloCrunchify]的servlet都映射到url模式,eclipse,tomcat,servlets,illegalargumentexception,servlet-mapping,Eclipse,Tomcat,Servlets,Illegalargumentexception,Servlet Mapping,我已经在eclipse中创建了一个动态web项目,如本文档所述: 当我在服务器上运行程序时,控制台中出现以下错误: Caused by: java.lang.IllegalArgumentException: The servlets named [Hello] and [com.crunchify.jsp.servlet.HelloCrunchify] are both mapped to the url-pattern [/CrunchifyServlet] which is not per

我已经在eclipse中创建了一个动态web项目,如本文档所述:

当我在服务器上运行程序时,控制台中出现以下错误:

Caused by: java.lang.IllegalArgumentException: The servlets named [Hello] and [com.crunchify.jsp.servlet.HelloCrunchify] are both mapped to the url-pattern [/CrunchifyServlet] which is not permitted
    at org.apache.tomcat.util.descriptor.web.WebXml.addServletMapping(WebXml.java:308)
    at org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet(ContextConfig.java:2373)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2055)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsWebResource(ContextConfig.java:1940)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsWebResource(ContextConfig.java:1934)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsWebResource(ContextConfig.java:1934)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsWebResource(ContextConfig.java:1934)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsWebResource(ContextConfig.java:1934)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1147)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:779)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:306)
    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:5150)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 6 more
我尝试从Servers选项卡中删除服务器,然后再次添加。把一个项目干净利落。似乎没有什么能解决这个问题

My 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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>CrunchifyJSPServletExample</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>Hello</servlet-name>
    <servlet-class>com.crunchify.jsp.servlet.HelloCrunchify</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Hello</servlet-name>
    <url-pattern>/CrunchifyServlet</url-pattern>
</servlet-mapping>

CrunchifyJSPServlete示例
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
你好
com.crunchify.jsp.servlet.hellocruncify
你好
/CrunchifyServlet

我正在使用Tomcat8,我的java主页设置为“
javac1.8.0\u05
” .
请帮忙

您省略了一些相关信息,包括其他servlet映射。 错误说明了一切:

Caused by: java.lang.IllegalArgumentException: The servlets named [Hello] and [com.crunchify.jsp.servlet.HelloCrunchify] are both mapped to the url-pattern [/CrunchifyServlet] which is not permitted
您有两个servlet映射,映射到同一个URI。 尝试将/CrunchifyServlet的URI更改为just/Crunchify

<servlet>
    <servlet-name>Hello</servlet-name>
    <servlet-class>com.crunchify.jsp.servlet.HelloCrunchify</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Hello</servlet-name>
    <url-pattern>/Crunchify</url-pattern>
</servlet-mapping>

你好
com.crunchify.jsp.servlet.hellocruncify
你好
/嘎吱作响

我认为堆栈跟踪的关键部分是:

The servlets named [Hello] and [com.crunchify.jsp.servlet.HelloCrunchify] are both mapped to the url-pattern [/CrunchifyServlet] which is not permitted
您需要删除这些servlet中的一个,或者消除url模式之间的冲突。您是否有另一个应用程序映射到相同的url模式?

试试这个:

C:\Program Files\Apache软件基金会\Apache Tomcat 8.x.xx\bin

发现

卡特琳娜蝙蝠

复制并粘贴到另一个驱动器,因为windows不允许您在此处编辑。 现在用任何编辑器打开文件

找到noJuliConfig和NojulicManager,您将到达类似于此图像的位置

您可以清楚地看到noJuliConfig和nojulicmanager的一个
set JAVA_OTPS=“Something”

现在您所要做的就是删除双引号,编辑后的零件将如下所示

现在只需将原来的catalina.bat替换为经过编辑的。 重新启动IDE。 你完成了


以后你可以为此感谢我D

这很奇怪,它说
/CrunchifyServlet
映射了两次,但我在web.xml上只能看到1个!谢谢你的回答。我编辑了我的url模式,它成功了。谢谢你的回答。我编辑了我的url模式,它成功了。我没有尝试,因为它是通过编辑Boo和pczeus提到的url模式来工作的。