Filter过滤器
来源:互联网 发布:应用程序监控软件 编辑:程序博客网 时间:2024/06/10 20:36
今儿在做个项目的时候,页面出现乱码,还以为是页面的encoding的编码问题,可是还是不行。
结果上网上查了下,说是使用filter过滤器来进行设置。因此就又重新把filter给看了一边:
Filter为过滤或过滤器,用于在servlet之外对request或者response进行修改。filter提出过滤连(FilterChain)的概念,一个FilterChain包含多个Filter。客户端请求request在抵达servlet之前会进过fulterchain里的所有Filter,服务器响应response在从servlet抵达客户端浏览器之前也会经过FilterChain里的所有filter:
filter必须实现javax.servlet.filter接口,filter接口有3个方法:
public void destroy() {// TODO Auto-generated method stub}public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {// TODO Auto-generated method stub}public void init(FilterConfig filterConfig) throws ServletException {// TODO Auto-generated method stub}filter需要在web.xml中进行配置才能生效:
<filter> <filter-name>outputReplaceFilter</filter-name> <filter-class>com.outputReplaceFilter</filter-class><init-param><param-name>file</param-name><param-value>/com/sensitive.properties</param-value></init-param> </filter> <filter-mapping> <filter-name>outputReplaceFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWORD</dispatcher> </filter-mapping>
- 过滤器Filter
- 过滤器Filter
- Filter 过滤器
- 过滤器 filter
- 过滤器filter
- 过滤器,Filter
- 过滤器Filter
- filter--过滤器
- 过滤器Filter
- filter过滤器
- Filter过滤器
- filter过滤器
- Filter过滤器
- Filter过滤器
- Filter 过滤器
- Filter过滤器
- Filter(过滤器)
- filter过滤器
- 第八周实验报告3
- 开始有目标的学习,努力!
- AS3 ComboBox ---- 下拉列表框类,又是细节是魔鬼啊
- 【GLSL教程】(八)纹理贴图
- mysql -> show profile ;
- Filter过滤器
- Go-Home – 12306 网上火车票自动订票程序
- 【GLSL教程】(九)其他说明
- stm32串口1收发
- hdoj1010
- jquery easyui table 典型应用
- 使用VC的Picture control在窗体上显示一副图片
- Rtems--c_user--系统配置
- C# 算法_排序