开发者

What is the purpose of <filter> tag in web.xml?

What is the purpose of <filter> ta开发者_如何学编程g in web.xml?


It allows you to declare servlet filters, which are aspects for HTTP requests. A filter chain can intercept an incoming request and/or an outgoing response and modify it as needed.

A common example is to have a filter that performs a GZIP compression on a response stream if the user's browser can accept it. This improves performance by reducing the number of bytes on the wire, provided that the savings is greater than the time to compress and decompress.


For declaring where a Servlet Filter should be applied. Here is a nice example of filter usage.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜