简体   繁体   中英

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

web.xml中<filter>标记的用途是什么?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM