1、重定向:
// 重定向
//修改響應行狀態碼,設值響應頭Location值
response.setStatus(302);
response.setHeader("Location", "/dy_01/loginSuccess.html");
//推薦方式
response.sendRedirect("/dy_01/loginSuccess.html");
2、修改響應頭Refresh// 兩秒後自動跳轉
response.setHeader("Refresh", "2;url=/dy_01/login.htm");
3、修改HTML mata頭利用js動態跳轉的方式<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!--
修改meta頭,實現5秒後自動跳轉
<meta http-equiv="Refresh" content="5;url=/day/demo_login/index.html">
-->
<title>Insert title here</title>
<script type="text/javascript">
var time = 5;
window.onload = function(){
setInterval('changeTime()',1000);
}
function changeTime(){
time--;
document.getElementById("spanId").innerHTML = time;
//當time爲0的時候重定向到另外一個頁面
if(time == 0){
location.href="/dy_01/index.html"
}
}
</script>
</head>
<body>
<h1>登錄成功</h1>
<h3>將在<span id="spanId"></span>秒後跳轉到主界面....</h3>
</body>
</html>