< jsp:forward page=” 要跳轉的頁面”>
< jsp:param value=”” name=””>
< / jsp:forward >
服務器內部跳轉,可帶參數!
代碼:
forward.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>2</title>
</head>
<body>
<jsp:forward page="target.jsp">
<jsp:param value="world" name="Str" />
</jsp:forward>
</body>
</html>
target.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>2</title>
</head>
<body>
服務器內部 跳轉後的頁面<br>
hello:<%=request.getParameter("Str") %>
</body>
</html>
運行結果:
結論:
1.服務器內部跳轉不會在地址欄顯示跳轉過程
2.服務器跳轉可以帶參跳轉