码迷,mamicode.com
首页 > Web开发 > 详细

jsp四大对象

时间:2017-03-01 14:02:14      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:.com   lan   use   href   tor   attr   text   ring   参数   

发送参数:

<a href="deal.jsp?id=1&user=用户&pwd=">处理页</a>

接收参数:

<%
String id = request.getParameter("id");
String user = request.getParameter("user");
String pwd = request.getParameter("pwd");
String notExist = request.getParameter("notExist");
%>

结果:

id参数为:1
user参数为:用户
pwd参数为:
notExist参数为:null

 

getAttribute.jsp

技术分享
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
    String result = request.getAttribute("result").toString();
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>getAttribute</title>
</head>
<body>
单价为: <%=result %>
</body>
</html>
View Code

<a href="getAttribute.jsp">getAttribute</a>:报错

<jsp:forward page="getAttribute.jsp"></jsp:forward>:成功

jsp四大对象

标签:.com   lan   use   href   tor   attr   text   ring   参数   

原文地址:http://www.cnblogs.com/lurenjia1994/p/6483637.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!