Tomcat 7 is a Servlet 3.0 compatible container. Since Servlet 3.0, the servlets can be configured by @WebServlet
annotation on the class without the need for a web.xml
configuration entry. Look closer at the servlet class you just created, there's a @WebServlet
annotation on it containing all information you specified in New Servlet wizard.
Effectively, this new way of configuring servlets
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {}
does exactly the same as this legacy way of configuring servlets
<servlet>
<servlet-name>helloServlet</servlet-name>
<servlet-class>com.example.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>helloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
If you still want Eclipse to create a web.xml
entry for some reason, then you should change the Dynamic Web Module version back from 3.0 to 2.5 in Project Facets section of project's properties.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…