更新时间:2021-10-30 23:42:38
Caused by: java.lang.IllegalArgumentException: The servlets named[ControllerServlet] 和 [com.classmgt.servlet.ControllerServlet] 是都映射到 url-pattern [/ControllerServlet] 这不是允许
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
您似乎混合了基于 @WebServlet
注释和基于 web.xml
的配置.
It seems that you have mixed @WebServlet
annotation based and web.xml
based configuration.
我怀疑您是否使用创建 Servlet"向导创建了一个 Servlet,该向导使用 url-pattern 创建 web.xml 条目,然后添加了一个 @WebServlet
注释,该注释复制了您可能放入的任何内容web.xml.
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.
您应该使用其中一个,而不是两者都使用.从 web.xml
中删除映射并继续使用 @WebServlet
注释.
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.
阅读更多:Servlet 3.0 注释 和 我们的 Servlets wiki 页面.