1

我已经创建了一个Eclipse动态Web项目在本文档中提及的网址模式:sampledoc抛出:IllegalArgumentException:你好]命名的servlet和[com.crunchify.jsp.servlet.HelloCrunchify]都映射到

当我在服务器上运行的程序,我得到这个错误在控制台:

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 

我试图从服务器选项卡中删除服务器并再次增加。项目干净了吗?似乎没有什么能解决问题。

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

我使用Tomcat 8和我的Java家被设定为 “javac 1.8.0_05” 。 请帮忙!!!

+0

这很奇怪,它说'/ CrunchifyServlet'被映射了两次,但我只能在web.xml中看到1! – Yazan

回答

1

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

The servlets named [Hello] and [com.crunchify.jsp.servlet.HelloCrunchify] are both mapped to the url-pattern [/CrunchifyServlet] which is not permitted 

你要么需要删除这些servlet的一个或解除冲突的网址模式。你有另一个应用程序映射到相同的网址模式?

+0

感谢您的回答。我编辑了我的网址模式,它工作。 – Sweet

1

您省略了一些相关信息,您的其他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。 试着改变的URI/CrunchifyServlet只/ 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> 
+0

感谢您的回答。我编辑了我的网址模式,它工作。 – Sweet

-1

试试这个:

转到

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

找到

catalina.bat

将其复制并粘贴到另一个驱动器中,因为Windows不会让您在此编辑。 现在用任何编辑器打开文件。

查找noJuliConfig和noJuliManager,你将到达的地方像这样的图像 Before Editing

你可以清楚地看到noJuliConfig和noJuliManager一个set JAVA_OTPS="Something"

现在你要做的是去掉双引号,一个编辑的部分看起来像这样After Editing

现在只需更换原有catalina.bat中与此编辑之一。 重新启动您的IDE。 你完成了。

您可以稍后为此感谢我。 :D

+0

我没有尝试过,因为它通过编辑Boo和pczeus提到的URL模式来工作。 – Sweet

相关问题