写一个number_1.jsp页面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h4>Number_1 Page</h4>
<!-- 我在number_1.jsp里面写个超链接,我要去number_2.jsp -->
<a href="number_2.jsp">To number_2 Page</a>
</body>
</html>
写一个number_2.jsp页面:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h4>Number_2 Page</h4>
<!-- number_2.jsp里面我要写请求转发和重定向的代码: -->
<%
//1.请求转发的代码:
//request.getRequestDispatcher("/number_3.jsp").forward(request, response);
//2.请求的重定向:
//response.sendRedirect("/number_3.jsp");//去number_3.jsp页面;
%>
</body>
</html>
运行一下:
本文出自 “IT技术JAVA” 博客,转载请与作者联系!
传智播客----javaWEB-请求的重定向之“对于爱情熟人真的不好下手吗”,古老的榕树,5-wow.com