jsp sendRedirect()方法进行跳转详解
直接跳转到hello.html页面 response_demo03.request属性保存到跳转页
response.sendRedirect()属于客户端跳转,地址会发生改变,不可以将request属性保存到跳转页
还有一个区别就是:服务端跳转会立刻跳转,而客户端跳转在整个页面执行完后才进行跳转
服务器端跳转response_demo04.jsp
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy5783')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy5783><%@ page language="java" contentType="text/html" pageEncoding="GBK"%>
<html>
<head>
<title>测试</title>
</head>
<body>
<%
System.out.println("----------forward跳转之前的-------------");
%>
<jsp:forward page="hello.html"/>
<%
System.out.println("----------forward跳转之后的-------------");
%>
</body>
</html>
显示结果:hello
但tomcat服务器后台显示----------forward跳转之前的-------------
客户端跳转 response_demo05.jsp
view sourceprint?<%@ page language="java" contentType="text/html" pageEncoding="GBK"%>
<html>
<head>
<title>测试</title>
</head>
<body>
<%
System.out.println("----------response跳转之前-------------");
%>
<%
response.sendRedirect("hello.html");
%>
<%
System.out.println("----------response跳转之后------------");
%>
</body>
</html>
tomcat服务器后台显示----------response跳转之前-------------
----------response跳转之后-------------
您可能感兴趣的文章:
jsp sendRedirect()方法进行跳转详解
servlet与jsp基础教程(8)-设置HTTP应答头
php和jsp之间有哪些区别
Struts2处理结果的学习笔记
JSP常见问题
php如何实现页面跳转
PHP 登录完成跳转上一访问页面
Jquery实现网页跳转或用命令打开指定网页的解决方法
PHP实现301跳转,及延时跳转代码
servlet与jsp基础教程(7)-HTTP应答状态