servlet 的控制缓存时间和response的重定向

//控制缓存时间
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String str = "aaaaaaaaaaaa"; response.setDateHeader("Expires",System.currentTimeMillis()+1*60*60*1000);//毫秒,控制缓存时间,相对于当前时间 response.getWriter().write(str); }

//response的重定向

  /*response.setStatus(302);
  response.setHeader("Location", "/day08_00_response/01Login.html");*/
  response.sendRedirect("/day08_00_response/01Login.html");

 
原文地址:https://www.cnblogs.com/zychengzhiit1/p/5038599.html