Servlet3.0及其以后版本 —— 注解的配置

Servlet3.0及其以后的版本,我们可以不在web.xml中配置项目的访问路径、资源路径,我们可以采用更简便的方式:注解,来配置。
使用方式:
在类上使用@WebServlet注解,进行配置。
例如:

@WebServlet(urlPatterns = "/demo") // 或者 @WebServlet("/demo")
public class Demo1_Servlet implements Servlet {}

猜你喜欢

转载自blog.csdn.net/weixin_41463971/article/details/88421730