filter 过滤缓存

时间:2023-02-11 00:30:27
package fifter;

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.annotation.WebFilter;
import javax.servlet.http.HttpServletResponse; @WebFilter("/*")
public class AcheTest implements Filter { @Override
public void destroy() {
// TODO 自动生成的方法存根 } @Override
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
throws IOException, ServletException {
HttpServletResponse resp = (HttpServletResponse) arg1;
resp.setDateHeader("expires", -1);
resp.setHeader("Cache-Control", "no-cache");
resp.setHeader("Pragma", "no-cache");
arg2.doFilter(arg0, arg1);
// TODO 自动生成的方法存根 } @Override
public void init(FilterConfig arg0) throws ServletException {
// TODO 自动生成的方法存根 } }