(十):跳转指令 (JSP学习第三天)

跳转指令:

语法: 不传递参数: <jsp:forward page="跳转的页面" />
  传递参数: <jsp:forward page="跳转的页面">
     <jsp:param name="参数名称" value="参数值"/>
     ........
      </jsp:forward>
     
跳转页:forward_demo01.jsp

<%@ page language="java" contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
</head>
<body>
<%
 String name="xiaoming";
%>
<jsp:forward page="forward_demo01.jsp">
 <jsp:param name="name" value="<%=name%>">
 <jsp:param name="info" value="helloworld">
</jsp:forward>
</body>
</html>

跳转之后的页面:forward_demo02.jsp

<%@ page language="java" contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
</head>
<body>
<h1>参数1:<%=request.getParameter("name")%></h1>
<h1>参数2:<%=request.getParameter("info")%></h1>
</body>
</html>
posted @ 2011-09-27 15:09  techstan  阅读(697)  评论(0编辑  收藏  举报