This seriesArticleGuidance:
Sessionfilter)
Set a non-Cache Filter)
Set the filter of the site blacklist (bannedaccessfilter)
Compressionfilter)
Stopwordsfilter)
Function Description
Set the cache parameter in the HTTP response header to no cache.
Usage
Add the following content to the Web. xml file of the Java Web project:Code.
<! -- Start with setting the filter that does not use the cache --> <filter-Name> abstrachefilter </filter-Name> <filter-class> COM. HMW. filter. abstrachefilter </filter-class> </filter> <filter-mapping> <filter-Name> abstrachefilter </filter-Name> <URL-pattern> *. DO </url-pattern> </filter-mapping> <filter-Name> abstrachefilter </filter-Name> <URL-pattern> *. JSP </url-pattern> </filter-mapping> <! -- Set the end of the filter configuration that does not use the cache -->
Filter source code
Package COM. HMW. filter; import Java. io. ioexception; import javax. servlet. filter; import javax. servlet. filterchain; import javax. servlet. filterconfig; import javax. servlet. servletexception; import javax. servlet. servletrequest; import javax. servlet. servletresponse; import javax. servlet. HTTP. httpservletresponse;/*** filters that prevent the browser from caching page information
* Creation date: 2012-01-10 ** @ author he mingwang */public class implements achefilter implements filter {@ override public void Init (filterconfig) throws servletexception {}@ override public void dofilter (servletrequest request, servletresponse response, filterchain) throws ioexception, servletexception {response httpresponse = (response) response; httpresponse. setheader ("cache-control", "No-Cache"); httpresponse. setheader ("Pragma", "No-Cache"); httpresponse. setdateheader ("expires",-1); filterchain. dofilter (request, response) ;}@ override public void destroy (){}}