新增注释

1、@webServlet

    主要属性:

    Servlet 3.0 新特性


2、@WebFilter

    主要属性:

    Servlet 3.0 新特性


3、@WebListener

    属性:value,可选属性,用于描述监听器信息


4、@WebInitParam

    等价于web.xml中的<servlet>和<filter>的<init-param>标签,配合@WebServlet或者@WebFilter使用。

    常用属性:

    Servlet 3.0 新特性


对文件上传的支持

实现文件上传需要以下两项:

  1. 添加@MultiPartConfig注解,需要标注在@WebServlet之上;
  2. 从request中获取Part文件对象。

@MultiPartConfig常用属性:

Servlet 3.0 新特性

还需要两个方法:

  1. Part getPart(String name);
  2. Collection<Part> getParts();


异步处理

应用于Servlet和过滤器两种组件,默认情况下不开启,如需开启:

  1. @WebServlet和@WebFilter注释中asyncSupported属性,默认false,如需开启,设为true。
  2. 如果是在web.xml中配置,则在<servlet>和<filter>中增加<async-supported>标签,设为true。







相关文章:

  • 2022-12-23
  • 2021-06-04
  • 2021-12-21
  • 2021-08-11
  • 2021-06-09
  • 2021-06-28
  • 2018-10-27
猜你喜欢
  • 2022-01-16
  • 2021-08-21
相关资源
相似解决方案