Servlet-浏览器不使用缓存

/**
 * @author CSDN_LQR
 * @TODO 设置浏览器不缓存
 */
public class ServletDemo extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        response.setHeader("pragma", "no-cache");
        response.setHeader("cache-control", "no-cache");
//      response.setIntHeader("expires", 0);
        response.setHeader("expires", "0");
    }
}

你可能感兴趣的:(JavaEE)