IllegalArgumentException阻止我启动tomcat

时间:2014-05-02 22:41:53

标签: java eclipse apache tomcat servlets

我正在使用tomcat 7.0服务器在Eclipse中处理动态Web应用程序和http-servlet。服务器没有突然启动,仍然返回以下异常:

java.lang.IllegalArgumentException: The servlets named [core.Flowpost_h1_h3] and [core.Flowpost_h2_h1] are both mapped to the url-pattern [/Flowpost] which is not permitted

我可以看到我的http servlet类“Flowpost_h1_h3”和“Flowpost_h2_h1”都有:

@WebServlet("/Flowpost")
public class Flowpost_h2_h1 extends HttpServlet {

@WebServlet("/Flowpost")
public class Flowpost_h1_h3 extends HttpServlet {

即使我正在更改其中一个类中的“/ Flowpost”,它仍会返回完全相同的错误。我需要在项目中修改什么才能摆脱这个问题?

我的web.xml:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.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>printinfo_rest</display-name>
  <servlet>
    <servlet-name>PrintInfo</servlet-name>
    <servlet-class>core.PrintInfo</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>PrintInfo</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

提前致谢

1 个答案:

答案 0 :(得分:0)

检查你是否还有一个带有Servlet映射的web.xml(它们会覆盖硬编码的映射):

<servlet-mapping>
    <servlet-name>Servlet1</servlet-name>
    <url-pattern>/path</url-pattern>
</servlet-mapping>