注解方式配置Servlet(Servlet3.0)
注解方式配置Servlet(Servlet3.0)
Servlet3.0 主页http://download.oracle.com/otndocs/jcp/servlet-3.0-fr-eval-oth-JSpec/
1、简单的servlet配置
@WebServlet(”/myservlet”)
@WebServlet(name=”MyServlet”, urlPatterns={"/myservlet", "/bar"})
xxx/myservlet就可用执行该servlet,而不需要在原来的web.xml配置servlet-name、servlet-class、url-pattern
2、属性的配置initParams
@WebFilter(urlPatterns="/*",
initParams={@WebInitParam(name="ignore",value = "/action/,/commons/")})
类似于
<init-param> |
<param-name>ignore</param-name> |
<param-value>/action/,/common/</param-value> |
</init-param> |