【问题标题】:The servlets named [AdminValidate] and [com.kunal.servlet.AdminValidate] are both mapped to the url-pattern [/AdminValidate] which is not permitted [duplicate]名为 [AdminValidate] 和 [com.kunal.servlet.AdminValidate] 的 servlet 都映射到不允许的 url 模式 [/AdminValidate] [重复]
【发布时间】:2014-10-01 13:09:56
【问题描述】:

当我尝试在我的项目中执行某些文件时,我会收到此错误

"Server Tomcat v7.0 Server at localhost 启动失败"

控制台显示以下错误

Caused by: java.lang.IllegalArgumentException: The servlets named [AdminValidate] and [com.kunal.servlet.AdminValidate] are both mapped to the url-pattern [/AdminValidate] which is not permitted
    at org.apache.catalina.deploy.WebXml.addServletMapping(WebXml.java:293)
    at org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet(ContextConfig.java:2396)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2072)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2033)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2026)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2026)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2026)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1291)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:876)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5378)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 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" 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>Agro</display-name>
  <servlet>
   <display-name>AdminValidate</display-name>
   <servlet-name>AdminValidate</servlet-name>
   <servlet-class>com.kunal.servlet.AdminValidate</servlet-class>
  </servlet>
  <servlet-mapping>
   <servlet-name>AdminValidate</servlet-name>
   <url-pattern>/AdminValidate</url-pattern>
  </servlet-mapping>
  <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>
</web-app>

我尝试了 stackoverflow 上的所有解决方案,但似乎没有任何帮助...如果有任何其他解决方案可以解决此问题,请在此处发布。

【问题讨论】:

  • 能否贴出web.xml代码和服务器代码
  • 我知道,是The servlets named [AdminValidate] and [com.kunal.servlet.AdminValidate] are both mapped to the url-pattern [/AdminValidate] which is not permitted引起的
  • 这看起来像问题:The servlets named [AdminValidate] and [com.kunal.servlet.AdminValidate] are both mapped to the url-pattern [/AdminValidate] which is not permitted.
  • 你在stackoverflow上究竟尝试过哪些解决方案? ^^
  • 我已经添加了 web.xml。我的项目中有一个 servlet,即 AdminValidate.java

标签: eclipse tomcat servlets illegalargumentexception servlet-mapping


【解决方案1】:

评论提供了答案,我仍然想发布作为答案

Caused by: java.lang.IllegalArgumentException: The servlets named [AdminValidate] and [com.kunal.servlet.AdminValidate] are both mapped to the url-pattern [/AdminValidate] which is not permitted

当您为同一个 URL 模式提供了多个 servlet 时,您希望容器如何为 URL 选择一个 servlet?

请检查 web.xml 中是否有多个 servlet 映射到相同的 URL 模式。

思考。

【讨论】:

  • 谢谢...错误已解决.....但现在我收到 HTTP 状态 500 - java.lang.NoSuchMethodError: javax.el.E​​xpressionFactory.newInstance()Ljavax/el/ExpressionFactory;
  • 方法javax.el.ExpressionFactory.newInstance() 是EL 2.2 的一部分。因此,您需要使用支持它的 servlet 容器。您使用哪个 tomcat 版本?
  • 它支持EL 2.2。不知道为什么会这样,请检查类路径中是否有任何 EL 2.1 jar 版本..
  • 谢谢兄弟......两个问题都解决了......我添加了错误的jar......
猜你喜欢
  • 2016-11-26
  • 2016-03-07
  • 1970-01-01
  • 2013-01-20
  • 2015-04-26
  • 2014-01-31
  • 1970-01-01
  • 2014-01-22
  • 2013-09-19
相关资源
最近更新 更多