(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区别的更多相关文章

  1. 【转】HttpServletRequest.getParameter() &HttpServletRequest.getAttribute() 区别

    Ref: HttpServletRequest的getParameter和getAttribute方法有什么区别 具体如下几点: (1)HttpServletRequest类有setAttribute ...

  2. JSP中getParameter和getAttribute区别

    (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方法 (2)当两个Web组件之间为链接关系时,被链接的组件通过getParameter ...

  3. request:getParameter和getAttribute区别

    getParameter 是用来接受用post个get方法传递过来的参数的.getAttribute 必须先setAttribute.(1)request.getParameter() 取得是通过容器 ...

  4. request中getParameter和getAttribute的区别

    整理一下getParameter和getAttribute的区别和各自的使用范围. (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方 ...

  5. Request的getParameter和getAttribute方法的区别

    下面整理一下getParameter和getAttribute的区别和各自的使用范围.      (1)HttpServletRequest类有setAttribute()方法,而没有setParam ...

  6. request.setAttribute和request.getAttribute还有session.setAttribute和session.getAttribute还有request.getParameter和request.getAttribute区别和联系

    1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...

  7. getParameter和getAttribute有什么区别

    1.getAttribute是取得jsp中 用setAttribute設定的attribute 2.parameter得到的是string:attribute得到的是object 3.request. ...

  8. Request的getParameter和getAttribute方法的差别

    HttpServletRequest.getParameter("modelName");能取到想要的modelObject吗?经过測试之后.发现是不能的. 后来想想.其它道理挺简 ...

  9. request.getParameter() 和request.getAttribute() 区别

    getParameter 是用来接受用post个get方法传递过来的参数的.getAttribute 必须先setAttribute.(1)request.getParameter() 取得是通过容器 ...

随机推荐

  1. 使用 TXT 文本存储

    将爬取的数据以 TXT 文本形式存储: import requests data = requests.get('http://www.baidu.com/').text with open('/tm ...

  2. Fragment获取Activity,Activity获取Fragment

    在界面布局文件中使用<fragment>元素添加Fragment时,可以为<fragment>元素指定android:id或android:tag属性,这两个属性都可用于标识该 ...

  3. MyEclipse中自定义maven命令(添加maven 命令)

    关于常用的Maven命令 mvn archetype:create :创建 Maven 项目 mvn compile :编译源代码 mvn test-compile :编译测试代码 mvn test ...

  4. pycharm2016.2.3注册码到期, 激活, 破解版

    python工具下载: https://pan.baidu.com/s/1kVEDOrl#list/path=%2F 密码:ko1i 注册码有效期是一年,到期后需再次激活 分享破解版 或者重新注册码激 ...

  5. 如何安装win10和linux [ubuntu14]双系统

    https://jingyan.baidu.com/article/4d58d5411380dd9dd5e9c07e.html jpg 改 rar 

  6. Qt——添加动作及对话框

    1. 添加动作 教程:https://www.devbean.net/2012/08/qt-study-road-2-action/ 运行教程中的第一个程序,报错如下: 原因:没有将main.cpp改 ...

  7. open-falcon之HBS

    功能 处理agent心跳请求,并将agent信息(ip.hostname.agent_version.plugin_version)等信息入库(portal库) 为agent提供执行run api的白 ...

  8. 利用腾讯云COS云对象存储定时远程备份网站

    版权声明:本文由张戈 原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/942851001487125915 来源:腾云阁 h ...

  9. LeetCode 13 Roman to Integer(罗马数字转为整数)

    题目链接 https://leetcode.com/problems/roman-to-integer/?tab=Description   int toNumber(char ch) { switc ...

  10. [原]openstack-kilo--issue(四) WARNING: nova has no endpoint in ! Available endpoints for this service:

    本博客已经添加"打赏"功能,"打赏"位置位于右边栏红色框中,感谢您赞助的咖啡. 在安装kilo的时候出现了一个报错 nova endpoints WARNING ...