过滤器对请求和响应的拦截,从而实现一些特殊的功能
过滤器的编写步骤
1、编写一个类,实现javax.servlet.Filter方法


2、配置要过滤的资源。web.xml


生命周期
l 诞生:应用被加载时。配置好的过滤器就会被容器实例化,接着初始化。
l 活着:应用活着,他就活着。针对用户的每次访问过滤器拦截范围内的资源,容器都会调用doFilter(SerlvetRequest,ServletResponse.FilterChain);
l 死亡:应用被卸载时,就会销毁。调用destory方法。