To create a Java filter filters

Is in a filter between a client and a server resource file filters, the Servlet information interception and processing, before accessing the resource file, to modify the request judgment through a series of filters. The filter may be filtered and modified before reaching the request Servlet. You can also be filtered or modified response.

filter filter creation process:

1: Create a class that implements the interface javax.servlet.Filter;

2: implement init () method reads the filter initialization parameters;

3: implement the doFilter () method, completion response function of a filter;

4: Implementing destroy () method, the destruction of the filter.

 

Filter MyFilter categories:

Configuring web.xml

Open access to the project under a tomcat jsp page, the console display:

 

Guess you like

Origin www.cnblogs.com/wangzhishi/p/10945721.html