这里是禁用缓存的方法:
package com.atguigu.javaweb.cache; import java.io.IOException; import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.atguigu.javaweb.HttpFilter; public class NoCacheFilter extends HttpFilter { @Override
public void doFilter(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws IOException, ServletException { System.out.println("cacheFilter's doFilter..");
//主要是这三个方法:
response.setDateHeader("Expires",-1);
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache"); filterChain.doFilter(request, response);
} }