jsp基础(三)跳转指令

语法格式

<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地址并没有变化

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值