1. 程式人生 > >如何用setHeader("refresh"...實現跳轉?

如何用setHeader("refresh"...實現跳轉?

2.用setHeader("refresh"...跳轉:


馬 克-to-win:使用response物件的setHeader()方法可以實現在某個時間點跳轉到某個頁面的作用。比如 response.setHeader("refresh",60);可以實現六十秒以後,又一次訪問當前頁面。而response.setHeader ("refresh","3;URL=http://localhost:8080/ServletHello/cookie.html"); 實現3秒後訪問新頁面:http://localhost:8080/ServletHello/cookie.html。



例:3.2.1


package 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 DeleteCookie extends HttpServlet {

詳情請見:http://www.mark-to-win.com/index.html?content=Jsp/jspUrl.html&chapter=Jsp/jsp2_web.html#setHeaderrefresh