求jsp页面跳转实例,5种方法,给3个方法的实例就好!
发布网友
发布时间:2022-05-05 22:42
我来回答
共2个回答
热心网友
时间:2022-04-24 06:29
经测试没有问题:
1. response.sendRedirct("跳转到页面");
2.response.setHeader();
<%
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
String newLocn="/index.html";
response.setHeader("Location",newLocn);
%>
3.<jsp:forward page="跳转页面"/>
4.JS自动跳转
<table>
<tr>
<td id= "go_title " >3秒后自动跳转到论坛首页 </td>
</tr>
</table>
var time=0;
function gotoBbsIndex(){
time++;
if(time==3){
document.location.href= "index.html ";
}
document.getElementById( "go_title ").innerHTML=(3-time)+ "秒后自动跳转到论坛首页 ";
}
window.setInterval( "gotoBbsIndex() ",1000);
</script>
5.<a href="#">转向的页面</a>
6.request.sendRedirect("success.html");
热心网友
时间:2022-04-24 07:47
response.sendRedirect(url)
<jsp:forward page="${url}"/>相当于request.getRequestDispatcher(url).forward(request,response);
out.print("<script type=\"javascript\">parent.location.href='" + url+"';</script>");