注解方式配置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>
posted @ 2014-12-08 18:11  乱七八糟 。  阅读(434)  评论(0编辑  收藏  举报