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

后端 未结 6 2005
深忆病人
深忆病人 2020-11-22 05:21

I tried to add this servlet

package com.classmgt.servlet;

@WebServlet(\"/ControllerServlet\")
public class ControllerServlet extends HttpServlet {}
         


        
6条回答
  •  广开言路
    2020-11-22 05:42

    What worked for me is doing a 'clean'.

    My issue was caused when the Servlet class was renamed. However, the original .class files remained in the target directory (with their Servlet annotation). It looks like you moved your ControllerServlet into a package.

    Jetty didn't seem to mind these apparent duplicates, but Tomcat7 gave your 'both mapped to the url-pattern' exception.

    The easy way to see if this is causing your issue is to look in the WAR to see if both the old classes (in your case [ControllerServlet] and [com.classmgt.servlet.ControllerServlet]) are both there.

提交回复
热议问题