forward的第二种使用方式

1、Example1.jsp

<%@ page contentType="text/html; charset=gb2312" language="java"%>
<% String str="This a String";%>
<jsp:forward page="JExample7_1.jsp" >
      <jsp:param name="hellostr" value="<%=str%>" />  //在跳转页面时要传递的参数,hellostr=“value”
</jsp:forward>

2、Example2.jsp

<%@ page contentType="text/html; charset=gb2312" language="java"%>
<center>
<%
 String str=request.getParameter("hellostr");
%>
   <h3>传递的字符串是:<BR>
    <%=str%>
</center>

猜你喜欢

转载自blog.csdn.net/qq_18062811/article/details/51171339