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

后端 未结 6 2072
深忆病人
深忆病人 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:56

    Caused by: java.lang.IllegalArgumentException: The servlets named [ControllerServlet] and [com.classmgt.servlet.ControllerServlet] are both mapped to the url-pattern [/ControllerServlet] which is not permitted

    It seems that you have mixed @WebServlet annotation based and web.xml based configuration.

    I doubt that you created a Servlet using the "Create Servlet" wizard which creates web.xml entry with url-pattern and then , added a @WebServlet annotation which duplicates anything you may put in the web.xml.

    You should use the one or the other, not both. Remove the mapping from web.xml and go ahead with using only the @WebServlet annotation.

    Read more: Servlet 3.0 Annotations and our Servlets wiki page.

提交回复
热议问题