Configure in web.xml
<servlet>
<!-- Servlet的名字-->
<servlet-name>hello</servlet-name>
<!-- Servlet类-->
<servlet-class>com.hrbu.web.HelloServlet</servlet-class>
</servlet>
<!-- 映射-->
<servlet-mapping>
<!-- 与上面的保持一致-->
<servlet-name>hello</servlet-name>
<!-- url,注意要以/开头-->
<url-pattern>/hello</url-pattern>
</servlet-mapping>
The access effect is the same as before
Configuring Servlets Using Annotations
As shown in the figure, the access effect is the same, and the name attribute here is not necessary.
The two configuration methods have their own advantages and disadvantages, Baidu.