What are the functions of filters I know?
1-character Transcoding
Request. setCharacterEncoding ("UTF-8 ");
2. Access Determination
Determine whether there are any illegal operations by using the value in the session
3-character filtering
Content = content. replace ("received characters", "changed ");
A filter is an object that can be preprocessed before the request arrives at Servlet/JSP, and then associated with the corresponding Servlet/JSP in the configuration file web. xml. You can use a filter to act on one or more servlets.
DoFilter (ServletRequest, ServletResponse, FilterChain): This method is used to perform and complete filtering.
Filter tag
<Filter>
<Filter-name> EncodingFilter </filter-name>
<Filter-class> sam. EncodingFilter </filter-class>
</Filter>
<Filter-mapping>
<Filter-name> EncodingFilter </filter-name>
<Url-pattern>/* </url-pattern>
</Filter-mapping>