码迷,mamicode.com
首页 > 编程语言 > 详细

JavaWeb-Refresh响应头

时间:2020-02-11 11:46:57      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:ted   public   end   write   xxx   tps   oid   代码示例   style   

一.Refresh响应头:可以理解为定时的重定向,在指定的时间后发生页面的跳转

 

二.代码示例:

package cn.xxx.Servlet;

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 DServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.getWriter().print("xxxx");
        //3秒之后跳转到/Demo01/EServlet
        response.setHeader("refresh", "3;URL=/Demo01/EServlet");
    }
}

 

package cn.xxx.Servlet;

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 EServlet extends HttpServlet {
    
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.getWriter().print("XXX");
    }


}

 

JavaWeb-Refresh响应头

标签:ted   public   end   write   xxx   tps   oid   代码示例   style   

原文地址:https://www.cnblogs.com/ibcdwx/p/12294170.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!