tomcat - 名为 [create_subscription] 和 [servlet.create] 的 servlet 都映射到不允许的 url-pattern [/create]

标签 tomcat servlets war

我在 JDK 7 中使用 Tomcat 7 和 Eclipse 来创建这个简单的 servlet 应用程序。但是当我将 war 文件复制到 tomcat 中时,我无法启动它并出现此错误:

The servlets named [create_subscription] and [servlet.create] are both mapped to the url-pattern [/create] which is not permitted

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" id="WebApp_ID" version="3.0">
<display-name>CC</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>create_subscription</servlet-name>
  <servlet-class>servlet.create</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>create_subscription</servlet-name>
  <url-pattern>/create</url-pattern>
</servlet-mapping>

</web-app>

最佳答案

如果您在 web.xml 和注解中声明了相同的映射,您将在更高版本的 Tomcat 中得到这个准确的错误。

关于tomcat - 名为 [create_subscription] 和 [servlet.create] 的 servlet 都映射到不允许的 url-pattern [/create],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14714706/

相关文章:

java - eclipse 项目 : tomcat server , jdk 、外部库等的设置

java - mysql-connector 8.0需要通过 `Class.forName()`注册驱动程序吗?

java - 处理ajax请求并发送响应java servlet

servlets - Servlet和路径参数如/xyz/{value}/test,如何在web.xml中映射?

tomcat - War 安装失败,因为未设置 Image Magic Home 环境变量(尽管我另有声明)

java - 什么软件可以帮助我解压 war 文件并获取其中的 java 源代码?

java - 无法通过服务器 IP 访问的 Spring Boot 应用程序给出 404

eclipse - 部署在 WTP (Eclipse) Tomcat : META-INF/context. xml 中的 Maven WebApp 未被复制过来(被忽略)

java - 为什么我在此 REST 教程中得到 404?

eclipse - Eclipse Indigo 中的 Tomcat 7 : Tomcat failing to start