JAVA-JSP内置对象之response对象实现页面跳转

 

相关资料:
《21天学通Java Web开发》

response对象

实现页面跳转
1.可以通过response对象的sendRedirect()方法设置页面重定向,从而实现页面跳转。
2.这种跳转将改变浏览器地址栏信息,所以也称为客户端跳转。

 

ResponseDemo.jsp

 1 <%@ page language="java" contentType="text/html;charset=gb2312" %>
 2 <html>
 3 <head>
 4   <title>设置页面跳转</title>
 5 </head>
 6 <body>
 7   <%-- 使用response对象的sendRedirect实现页面跳转 --%>
 8   <%
 9     response.sendRedirect("DirectPage.jsp");//进行页面跳转
10   %>
11 </body>
12 </html>
View Code

 

DirectPage.jsp

1 <%@ page language="java" contentType="text/html;charset=gb2312" %>
2 <html>
3 <head>
4   <title>跳转到页面</title>
5 </head>
6 <body>
7   <h4>跳转到页面</h4>
8 </body>
9 </html>
View Code

 

posted on 2017-10-15 10:42  疯狂delphi  阅读(1607)  评论(0编辑  收藏  举报

导航