与上面的帖子类似,但是该代码存在一些问题。这将禁用所有浏览器缓存:
import javax.servlet.*;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.util.Date;public class CacheControlFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse resp = (HttpServletResponse) response; resp.setHeader("Expires", "Tue, 03 Jul 2001 06:00:00 GMT"); resp.setDateHeader("Last-Modified", new Date().getTime()); resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); resp.setHeader("Pragma", "no-cache"); chain.doFilter(request, response); }}
然后按照StuThompson的answer中的描述映射到web.xml中。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)