I had a Dynamic Web project which had a few @WebServlet annotations, all of which worked fine. I have since switched my Dynamic Web project to a Maven web project. Since doing so, I can’t access any of my servlets by what I defined in my @WebServlet annotations. I should also note that some of my servlets are overlay from other Maven projects. Do I have to now define my servlet mappings in the web.xml file?
Thanks
The Maven story aside, the
@WebServletannotation was introduced in Servlet 3.0. If they are not initialized, then it simply means that either the web application descriptor (theweb.xml) is not declared conform Servlet 3.0 or that the target container does not support Servlet 3.0.You need to verify if your
web.xmlconforms Servlet 3.0. I.e., the<web-app>root declaration must match that: