0

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

“本地主机上的服务器 Tomcat v7.0 服务器无法启动”

控制台显示以下错误

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上尝试了所有解决方案,但似乎没有任何帮助......如果有任何其他解决方案可以解决这个问题,请在此处发布。

4

1 回答 1

0

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

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 中是否有多个映射到同一 URL 模式的 servlet。

思考。

于 2014-08-08T06:17:10.720 回答