当前位置: 代码迷 >> Web前端 >> java WEB Response重定向缓和存控制
  详细解决方案

java WEB Response重定向缓和存控制

热度:594   发布时间:2013-09-13 21:12:00.0
java WEB Response重定向和缓存控制
package cn.com;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ResponseChongdingxiang extends HttpServlet {
	private static final long serialVersionUID = 1L;
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.sendRedirect("/Response/MyHtml.html");
		
		/* 
		 response.setStatus(302);
		 response.setHeader("location", "url=/Response/MyHtml.html");
		*/
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}
package cn.com;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ResponseHuancun extends HttpServlet {
	private static final long serialVersionUID = 1L;
  
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String str="aaaaaaa";
		response.setDateHeader("expries", System.currentTimeMillis()+1000*3600);
		
		response.getWriter().write(str);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}

  相关解决方案