JSP两个动作(include,forward)

include动作

<div id="container">
<jsp:include page="HelloWorld.jsp" flush="true|false">
<jsp:param value="xiaoming" name="username"/>
</jsp:include>
</div>

flush默认值为false

Forward动作

跳转页面 forward.jsp

<jsp:forward page="another.jsp?username=xiaoming">
<jsp:param value="18" name="age"/>
</jsp:forward>

接受页面 another.jsp

<h1>Hello World!
<%= request.getParameter("username")%>
<br>
age is:
<%= request.getParameter("age")%>
</h1>

跳转页面:forward.jsp

<jsp:forward page="sayHello.jsp">
<jsp:param name="user" value="world"/>
<jsp:param name="user" value="George"/>
</jsp:forward>

sayhello.jsp

<%@page import="java.util.*"%>
<html>
<head><title>Say Hello</title></head>
<body>
<h2><center>Hello, <%=request.getParameter("user")%><br/>
The values of parameter user are :
<%
String[] values = request.getParameterValues("user");
for(int i = 0; i < values.length; i++){
%>
<%=values[i]%>
<%}%>
</center></h2>
</body>
</html>
上一篇:Android 组件系列-----Activity的传值和回传值


下一篇:Visual Studio 2013支持Xamarin的解决方案