过滤器一般常用的功能

在我们日常开发中,新建一个项目的时候一般都会添加过滤器,进行对来自外部的请求进行一些预处理或者过滤,那么对于过滤器我们可以做哪些功能呢?

我们可以直接看过滤器的api:
Filter
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.

Filters perform filtering in the doFilter method. Every Filter has access to a FilterConfig object from which it can obtain its initialization parameters, a reference to the ServletContext which it can use, for example, to load resources needed for filtering tasks.

Filters are configured in the deployment descriptor of a web application

Examples that have been identified for this design are
1) Authentication Filters
2) Logging and Auditing Filters
3) Image conversion Filters
4) Data compression Filters
5) Encryption Filters
6) Tokenizing Filters
7) Filters that trigger resource access events
8) XSL/T filters
9) Mime-type chain Filter

英文不及格直接百度翻译:
滤波器
过滤器是一个对象,它对资源(servlet或静态内容)的请求执行过滤任务,或对资源的响应,或两者都执行过滤任务。
滤波器进行滤波的doFilter方法。每个过滤器已获得从它可以获得它的初始化参数的filterconfig对象,参照ServletContext它可以使用,例如,加载过滤任务所需要的资源。
过滤器配置在Web应用程序的部署描述符中。
为这种设计确定的示例是
1)身份验证过滤器
2)日志和审计过滤器
3)图像转换滤镜
4)数据压缩滤波器
5)加密过滤器
6)标记过滤器
7)触发资源访问事件的过滤器
8)XSL / T过滤器
9)MIME类型链式过滤器

这里面有9个可以用的功能,当然可能还可以实现其他功,以后遇到会更新上去

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值