【问题标题】:IllegalArgumentException which prevents me to start tomcatIllegalArgumentException 阻止我启动 tomcat
【发布时间】:2014-06-19 17:18:15
【问题描述】:

我正在使用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>

提前致谢

【问题讨论】:

    标签: java eclipse apache tomcat servlets


    【解决方案1】:

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

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

    【讨论】:

    • 感谢您的回复。是的,我有,我也添加了我的 web.xml
    • 有问题的 servlet 未在 web.xml 中定义(因此这不会导致您的问题)。还可以尝试取消部署、重新启动和部署。
    • 我已经保存了我的项目,用Eclipse删除了虚拟机,然后重新安装了它,但错误重复
    猜你喜欢
    • 1970-01-01
    • 2014-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多