package zdh.cm.response;
/*
* 定时刷新页面或跳转到其他页面
*/
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ResponseDemo3 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//防止输出乱码
response.setContentType("text/html;charset=utf-8");
//设置页面每隔2秒刷新一次
//response.setHeader("refresh", "2");
//设置3秒后跳到下载页面
response.getWriter().write("3秒后跳到下载页面");
response.setHeader("refresh", "3; /Http/downing.html");
}
}
http协议之response案例二:定时刷新页面或跳转到其他页面
最新推荐文章于 2021-08-03 20:10:44 发布