IllegalArgumentException:名为[Hello]和[com.crunchify.jsp.servle



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

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

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>

我使用的是Tomcat8,我的java主页设置为"javac 1.8.0_05"。请帮忙!!!

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

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模式吗?

您已经省略了一些相关信息,您的其他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。尝试将/CrunchfyServlet的URI更改为仅/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>

试试这个:

转到

C: \Program Files\Apache Software Foundation\Apache Tomcat 8.x.xx\bin

查找

catalina.bat

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

找到noJuliConfig和noJuliManager,你会到达这样的地方编辑之前

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

现在你所要做的就是删除双引号,编辑后的部分会像这样。编辑后

现在,只需将原始的catalina.bat替换为这个经过编辑的。重新启动IDE。你就完了。

你可以稍后感谢我D

相关内容

最新更新