语法格式
<jsp:forward page="result.jsp">
<jsp:param value="from forward.jsp" name="content"/>
</jsp:forward>
实例:有两个页面:forward.jsp 和result.jsp
forward.jsp页面代码
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!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=GB18030">
<title>Insert title here</title>
</head>
<body>
<jsp:forward page="result.jsp">
<jsp:param value="from forward.jsp" name="content"/>
</jsp:forward>
</body>
</html>
result.jsp页面代码
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!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=GB18030">
<title>Insert title here</title>
</head>
<body>
<h1>这是跳转后的页面</h1>
<%
String content=request.getParameter("content");
%>
<%=content %>
</body>
</html>
访问forward.jsp后的效果
总结:从访问效果可以看出我们的参数所对应的值已经被result.jsp接收,页面页面显示的是result的内容。但是地址栏,的路径没有变化。这种情况叫做服务器端跳转,主要指 服务器定位到另一个页面并把内容返回给客户端,但是客户端这边的url地址并没有变化