getParameter和getAttribute区别
(1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方法
(2)当两个Web组件之间为链接关系时,被链接的组件通过getParameter()方法来获得请求参数,
(3)当两个Web组件之间为转发关系时,转发目标组件通过getAttribute()方法来和转发源组件共享request范围内的数据。
(4)一般通过表单和链接传递的参数使用getParameter
(5)通过request.setAttribute("name","jerry")的方式赋值,然后使用request.getAttribute("name")在另一页面取得值与sesssion有相似的功能。
区别在于范围大小。request范围较小一些,只是一个请求,简单说就是你在页面上的一个操作,request.getParameter()就是从上一个页面中的url、form中获取参数,
但如果一个request涉及多个类,后面还要取参数,可以用request.setAttribute()和request.getAttribute(),但是当结果输出之后,request就结束了。
而session可以跨越很多页面,比如很多网站的用户登录都用到了。
getParameter和getAttribute区别的更多相关文章
- 【转】HttpServletRequest.getParameter() &HttpServletRequest.getAttribute() 区别
Ref: HttpServletRequest的getParameter和getAttribute方法有什么区别 具体如下几点: (1)HttpServletRequest类有setAttribute ...
- JSP中getParameter和getAttribute区别
(1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方法 (2)当两个Web组件之间为链接关系时,被链接的组件通过getParameter ...
- request:getParameter和getAttribute区别
getParameter 是用来接受用post个get方法传递过来的参数的.getAttribute 必须先setAttribute.(1)request.getParameter() 取得是通过容器 ...
- request中getParameter和getAttribute的区别
整理一下getParameter和getAttribute的区别和各自的使用范围. (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方 ...
- Request的getParameter和getAttribute方法的区别
下面整理一下getParameter和getAttribute的区别和各自的使用范围. (1)HttpServletRequest类有setAttribute()方法,而没有setParam ...
- request.setAttribute和request.getAttribute还有session.setAttribute和session.getAttribute还有request.getParameter和request.getAttribute区别和联系
1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...
- getParameter和getAttribute有什么区别
1.getAttribute是取得jsp中 用setAttribute設定的attribute 2.parameter得到的是string:attribute得到的是object 3.request. ...
- Request的getParameter和getAttribute方法的差别
HttpServletRequest.getParameter("modelName");能取到想要的modelObject吗?经过測试之后.发现是不能的. 后来想想.其它道理挺简 ...
- request.getParameter() 和request.getAttribute() 区别
getParameter 是用来接受用post个get方法传递过来的参数的.getAttribute 必须先setAttribute.(1)request.getParameter() 取得是通过容器 ...
随机推荐
- 网站前端性能优化之javascript和css
之前看过Yahoo团队写的一篇关于网站性能优化的文章,文章是2010年左右写的,虽然有点老,但是很多方面还是很有借鉴意义的.关于css的性能优化,他提到了如下几点: CSS性能优化 1.把样式表置于顶 ...
- [Ubuntu] 关于使用 root 账号登录
(本文验证环境为 Ubuntu 14.04 和 Lubuntu 13.04) Ubuntu 维护者们认为实在没有必要使用 root 帐户,因为你想做的所有事情管理员都可以完成,管理员只需使用 sudo ...
- (转)C语言中长度为0的数组
前面在看Xen的源码时,遇到了一段代码,如下所示: 注意上面最后一行的代码,这里定义了一个长度为的数组,这种用法可以吗?为什么可以使用长度为0 的数组?长度为的数组到底怎么使用?……这篇文章主要针对该 ...
- PHP 中文字符串截取
$str = "abcdef啊啊吧啊"; function my_sub($str, $st ,$len){ $ret = ""; for( $st; $len ...
- [转]java中判断字符串是否为数字的三种方法
1用JAVA自带的函数public static boolean isNumeric(String str){ for (int i = str.length();--i>=0;){ ...
- 三.jquery.datatables.js表格编辑与删除
1.为了使用如图效果(即将按钮放入行内http://www.datatables.net/examples/ajax/null_data_source.html) 采用了另一个数据格式 2.后台php ...
- liunx trac 插件使用之DateFieldPlugin
插件GanttCalendarPlugin安装完以后,有一个问题,就是在选择起始与结束时间的时候,为了方便有datepicker功能,如图 需要用到插件DateFieldPlugin,官网链接http ...
- css3整理--border-radius
1.border-radius 标准: border-top-left-radius: x y // 左上角,x 圆角水平半径, y 圆角垂直半径 border-top-right-radius:x ...
- UE和UI的区别
UI:User Interface的缩写,是指用户界面,最普遍的应用是在软件开发中,主要是指程序的用户操作界面的设计,随着Web应用的普及,UI也应用在了Web的用户界面规划上了.网站用户界面(Web ...
- C# 输出带颜色文字,用于实时日志输出
private void button1_Click(object sender, EventArgs e) { LogMessage("绿色"); 4 LogError(&quo ...