zl程序教程

您现在的位置是:首页 >  后端

当前栏目

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

JAVAJSP对象 实现 页面 跳转 内置 response
2023-09-14 08:57:11 时间

 

相关资料:
《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