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

相关文章:

  • 2021-11-03
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-04
  • 2022-12-23
  • 2021-12-05
  • 2021-06-13
  • 2021-10-20
  • 2022-12-23
  • 2022-01-09
相关资源
相似解决方案