HttpServletRequest的Attribute和Parameter区别
HttpServletRequest类既有getAttribute()方法,也由getParameter()方法,这两个方法有以下的组件通过getParameter()方法来获得请求参数,例如假定welcome.jsp和authenticate.jsp之间为链接关系,welcome.jsp中有以下代码:
<a href="authenticate.jsp username=weiqin">authenticate.jsp a>
html 代码
或者:
<form name="form1" method="post" action="authenticate.jsp">
请输入用户姓名:<input type="text" name="username"><input type="submit" name="Submit" value="提交">form>
在authenticate.jsp中通过request.getParameter("username")方法来获得请求参数
username:<% String username=request.getParameter("username"); %>
html 代码
在authenticate.jsp中通过request.getParameter("username")方法来获得请求参数username:
(3)当两个Web组件之间为转发关系时,转发目标组件通过getAttribute()方法来和转发源组件共享 request范围内的用户名字,如何传递这一数据呢?先在authenticate.jsp中调用setAttribute()方法:
在hello.jsp中通过getAttribute()方法获得用户名字:Hello:
(4)从更深的数据,会从Web客户端传到Web服务器端,代表HTTP请求数据。request.getParameter()方法返回String类型的数据只会存在于Web容器内部,在具有转发关系的共享数据。
getParameter得到的。或者是http://a.jsp id=123中的数据。
getAttribute则可以是对象。
getParameter()是获取POST/GET传递的数据值;
getParameter:用于客户端重定向时,即点击了链接或提交按扭时传值用,即用于在用表单或url重定向传值时接收数据用。
getAttribute:用于服务器端重定向时,即在sevlet中使用了forward函数,或struts中使用了mapping.findForward。getAttribute只能收到程序用setAttribute传过来的一块内存中去,当你的内存中。这样getAttribute就能取得你所设下的生命周期不一样而已。
getParameter只是应用服务器在分析你送上来的文本时,取得你设在表单或url重定向时的值
HttpServletRequest的Attribute和Parameter区别的更多相关文章
- attribute与parameter区别(转)
文章转自http://blog.csdn.net/saygoodbyetoyou/article/details/9006001 request.getParameter取得Web客户端到web服务端 ...
- Request中Attribute 和 Parameter 的区别
Attribute 和 Parameter 的区别 (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方法 (2)当两个Web组件之间为 ...
- Attribute 和 Parameter 的区别
Attribute 和 Parameter 的区别 (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方法 (2)当两个Web组件之间为 ...
- 参数(parameter)和属性(Attribute)的区别
参数(parameter)和属性(Attribute)的区别 区别: 来源不同: 参数(parameter)是从客户端(浏览器)中由用户提供的,若是GET方法是从URL中 提供的,若是POST方法是从 ...
- [attribute|=value]和[attribute^=value]选择器区别
1.[attribute|=value] [attribute|=value]选择器说明:http://www.w3school.com.cn/cssref/selector_attribute_va ...
- jQuery的attr与prop,attribute和property区别
jQuery1.6中新添加了一个prop方法,看起来和用起来都和attr方法一样,这两个方法有什么区别呢?这要从HTMl 的attribute与property区别说起,attr与prop正是这两个东 ...
- attribute与property区别总结
在前阵子看JQuery源码中,attr()的简单理解是调用了element.getAttribute()和element.setAttribute()方法,removeAttr()简单而言是调用ele ...
- CSS选择器[attribute | = value] 和 [attribute ^ = value]的区别
前言 首先你需要知道[attribute | = value] 和 [attribute ^ = value] 分别是什么? ①:[attribute | = value] ②:[attribute ...
- parameter与attribute的使用场合(转载自草原和大树)
Attribute 和 Parameter 的区别 (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方法 (2)当两个Web组件之间为 ...
随机推荐
- thinkphp 动态 级联
<div class="form-item"> <label class="item-label">一级分类<span class ...
- MVC 微信扫码支付
微信扫码支付有两种模式, 模式一和模式二, 两者具体的区别可参考官网文档:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4 微 ...
- De4Dot+Reflector 支持多种反混淆
官网: http://www.de4dot.com/ 源码:https://github.com/brianhama/de4dot 使用方法 通过CMD命令方式进入: F:\2\de4dot-v3-1 ...
- HTTP、TCP、UDP以及SOCKET之间的区别/联系
一.TCP/IP代表传输控制协议/网际协议,指的是一系列协组. 可分为四个层次:数据链路层.网络层.传输层和应用层. 在网络层:有IP协议.ICMP协议.ARP协议.RARP协议和BOOTP协议. 在 ...
- Register DLL Assembly Gacutil.exe(全局程序集缓存工具)
全局程序集缓存工具使你可以查看和操作全局程序集缓存和下载缓存的内容. 此工具会自动随 Visual Studio 一起安装. 若要运行此工具,请使用开发人员命令提示(或 Windows 7 中的 Vi ...
- OPENWRT开始SFTP支持办法
root@OpenWrt:~# opkg update root@OpenWrt:~# opkg install vsftpd openssh-sftp-server root@OpenWrt:~# ...
- 2-6 Working with Lambdas
在C++中使用匿名函数,格式如下:[] () {}; Using a Lambda to Print array Values #include <algorithm> #include ...
- aa3
var geoCoordMap = { "海门":[121.15,31.89], "鄂尔多斯":[109.781327,39.608266], "招远 ...
- Dreamweaver 升级问题汇总
Adobe的产品开始从CC (Creative Cloud) 开始转向云平台,CS将逐渐成为过去时.不过CC并不限制用户在同一台机器上同时使用CS和CC,这种策略估计要持续较长一段时间. If you ...
- exe文件放在其他位置
set PATH=%PATH%;%UGII_ROOT_DIR%call "E:\ZY\exe\uds_rename_parts_mohao.exe"E:\ZY\exe\uds_re ...