Servlet3.0中可以使用注解(annotation)替代web.xml进行配置;
通常用的注解有五种类型:
@WebServlet:对Servlet进行配置
@WebInitParam:配置Servlet初始化参数
@WebFilter:配置过滤器
@WebListener :配置监听器
@MultipartConfig:对文件上传的支持
@WebServlet:对Servlet进行配置示例,包括的属性如下,这些属性除了vlaue或urlPatterns是必选的,其他的都是可选的:
1)name:等价于web.xml配置文件中的
2)urlPatterns:等价于web.xml配置文件中的
3)value:等价于 urlPatterns 属性。
4)loadOnStartup:等价于web.xml配置文件中的
5)initParams :等价于web.xml配置文件中的
6)asyncSupported:等价于web.xml配置文件中的
7)description:等价于web.xml配置文件中的
8)displayName:等价于web.xml配置文件中的