jsp/servlet第三章第五節jsp跳轉指令

< 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.服務器跳轉可以帶參跳轉
這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章