filter 过滤器 禁止浏览器缓存
1 public class BrowserNoCacheFilter implements Filter { 2 public void init(FilterConfig filterconfig) throws ServletException { 3 } 4 public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterchain) throws IOException, ServletException { 5 ((HttpServletResponse) response).setHeader("Cache-Control", "no-cache"); //HTTP消息头,控制网页的缓存 6 ((HttpServletResponse) response).setHeader("Pragma", "no-cache"); //禁止浏览器从缓存中调阅页面内容 7 ((HttpServletResponse) response).setHeader("Expires", "-1"); //指定网页在缓存中的过期时间 8 filterchain.doFilter(request, response); 9 } 10 public void destroy() { 11 } 12 }