zoukankan      html  css  js  c++  java
  • [技巧篇]18.过滤器编写一个刷新用户端最新缓存的

    public class NocacheFilter implements Filter {
        
        public void doFilter(ServletRequest request,
                ServletResponse response,
                FilterChain chain) throws IOException, ServletException {
            
            HttpServletResponse httpResponse = (HttpServletResponse)response;
            httpResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
            httpResponse.setHeader("Pragma", "no-cache");
            httpResponse.setDateHeader("Expires", 0);
            
            chain.doFilter(request, response);
        }
        
        public void destroy() {}
        public void init(FilterConfig fConfig) throws ServletException {}
    }

    这个我就是备注一下,就不发布了,需要在web.xml中注册一下或者使用Servlet3.0的版本@WebFilter

  • 相关阅读:
    缅怀
    74LS164的使用
    跑步
    Datasheet,你会读么?[转]
    清华附小给的书单
    iOS-小知识
    网络-GET&POST
    网络-基础
    网络-HTTP其他常见方法
    数据解析
  • 原文地址:https://www.cnblogs.com/pangxiansheng/p/4863398.html
Copyright © 2011-2022 走看看