Several tags added by Servlet3.0

1. @WebFilter

 

@WebFilter("/*")
public class SessionFilter implements Filter {
     ...
}

 You can easily add a filter.

 

2. @WebServlet

 

pass through:

 

@WebServlet (
// Servlet access URL, you can configure multiple access paths using an array
urlPatterns = { "*.do", "*.mvc", "*.ftl" },
// Servlet initialization parameters
initParams = { @WebInitParam(name = "config-file", value = "/WEB-INF/config/mvc.xml") },
name = "mvc", description = "tntxia web mvc 入口Servlet")
public class DispatchServlet extends HttpServlet {
      ......

}

 

In this form, we can easily add servlets without configuring servlet information in Web.xml

 

3. @WebListener

 

This tag can add a Listener, and there is no need to add Listener configuration in webx.ml.

 

Such as:

@WebListener
public class InitListener implements ServletContextListener {
....
}

 

 Summary: The tags added by Servlet 3.0 make us do not need to use web.xml, so as to realize the pluggability of Web components

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326443413&siteId=291194637