标签:
package javax.servlet; import java.io.IOException; /** * A filter is an object that performs filtering tasks on either the * request to a resource (a servlet or static content), or on the response * from a resource, or both. * @since Servlet 2.3 */ public interface Filter { /** * Called by the web container to indicate to a filter that it is * being placed into service. */ public void init(FilterConfig filterConfig ) throws ServletException; /** * The <code> doFilter</code> method of the Filter is called by the * container each time a request/response pair is passed through the * chain due to a client request for a resource at the end of the chain. * The FilterChain passed in to this method allows the Filter to pass * on the request and response to the next entity in the chain. */ public void doFilter(ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException, ServletException; /** * Called by the web container to indicate to a filter that it is being * taken out of service. */ public void destroy(); }
<!-- Char encoding --> <filter > < filter-name> characterFilter </filter-name > < filter-class> space.ifei.wxchat.sys.CharacterFilter </filter-class > <!-- <async-supported>true</async-supported> --> <!-- <init- param> --> <!-- <param-name>XXX</param-name> --> <!-- <param-value>QQQ</param-value> --> <!-- </init- param> --> </filter > <filter-mapping > <filter-name> characterFilter </filter-name > <!-- 同一个Filter,Filter的名字必须一致 --> <url-pattern> /* </url-pattern > <!-- Filter生效的 url规则,可以使用通配符 --> <!-- <dispatcher>REQUEST</dispatcher> --> <!-- <dispatcher>FORWARD</dispatcher> --> </filter-mapping >
标签:
原文地址:http://www.cnblogs.com/mr-frank/p/5521218.html