request.getAttribute():是request时设置的变量的值,用request.setAttribute("name","您自己的值");来设置值,   
request.getParameter():提取发送过来的参数如:本网页http://community.abc.net/Expert/topic/4633/4633804.xml?temp=.3488123  
request.getParameter("temp")==".3488123"
request.getParameter  
  是用来接受来自get方法或post方法的参数  
     <form      method=post>  
     <form      method=get>  
     <a      href="1.jsp?id=1">ok</a>  
  只能接受java.lang.String  
  也就是说String      hotel_id      =      request.getParameter("hotel_id");  
     request.getAttribute  
  是用来接受来自servlet的变量或Action(其实Action就是特殊的Servlet)  
  在Action中,request.setAttribute("ret",ret);  
  只能接受java.lang.Object  
  也就是说List      ret      =      (List)request.getAttribute("ret");  
  如果你只用JSP,根本用不到request.getAttribute()

request.getAttribute()和request.getParameter()的区别是request.getAttribute()获得的是对象类型,

而request.getParameter()获得的是字符串类型
一般的网页应用,基本上是基于Post方式的传递,用getParameter

取值。对于自己控制的,可以通过request.setAttribute和getAttribute   实现值得传递。  
  对于应用Structs框架的,getAttribute用的多一点,其他的基本上用getParameter

我的理解:
session.getAttribute();获得session
request.getParameter();获得parameter

1.getParameter可以获得客户端传送给服务器端的参数值。   
     getAttribute可以得到由setAttribute设置的参数值,就相当于是使用getAttribute得到一个自己定义

的参数,而不是从客户端得到的参数。
2.getParameter只能传递string类型的变量,getAttribute能传递vector。

getParameter(),获取表单的值 getAttribute()获得session的值

getParameterNames() 获得表单或则url中的参数的数组
getattributeNames():返回request对象所有属性的名字,结果集是一个Enumeration(枚举)类的实例

根据楼上,是不是 getParameter()得到的值如果下次不提交或保存起来的话,下次重定向后就没啦?
:理解对了
getAttribute()所要得到的属性值因为存在session中,所以重定向后仍可以取出?
getAttribute()在request和session中都有,只是作用域不同,在取之前肯定是要在某个地方存一下,这种

东东可以存取对象

http://community.abc.net/Expert/topic/4763/4763471.xml?temp=.1793177
看见后面的?temp=.1793177没有,?号后面的这个东西用request.getAttribute("temp")就能得到字符

串".1793177",
而getAttribute()之前,你必须在页面或者逻辑中用serAttribute()设置了才能用,已经很清楚了,我不再

说了哈

Parameter是html裡傳來的像 checkbox textfield password radio ...的value
getAttribute是取得jsp中用setAttribute設定的attribute

還有....
parameter得到的是string
attribute得到的是object

个人经验:当用forward标签及request.getRequestDispatcher.forward()时,可以用setAttribute和getAttribute,表单提交和超链接提交都只能读取name属性相关的value,用getParameter();reponse.sendRediretion("MyJsp.jsp?username=luocong"),这样也可以用getParameter("username")来提取.

Get 方法通过 URL 请求来传递用户的数据,将表单内各字段名称与其内容,以成对的字符串连接,置于 action 属性所指程序的 url 后,如[url]http://www.mdm.com/test.asp?name=asd&password=sad[/url],数据都会直接显示在 url 上,就像用户点击一个链接一样;Post 方法通过 HTTP post 机制,将表单内各字段名称与其内容放置在 HTML 表头(header)内一起传送给服务器端交由 action 属性能所指的程序处理,该程序会通过标准输入(stdin)方式,将表单的数据读出并加以处理

request.setAttribute无法用表单提交的原因,设定值的request,与表单请求的request不是一个request,不是同一时间生成的。

getParameter 与 getAttribute的区别的更多相关文章

  1. request中getParameter和getAttribute的区别

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

  2. getParameter和getAttribute的区别

    1.getAttribute 是取得jsp中 用setAttribute 设定的attribute 2.parameter得到的是String:attribute得到的是object 3.reques ...

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

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

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

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

  5. getParameter和getAttribute有什么区别

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

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

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

  7. 〖转〗request.getparameter()和request.getAttribute()的区别

    getAttribute表示从request范围取得设置的属性,必须要先setAttribute设置属性,才能通过getAttribute来取得,设置与取得的为Object对象类型 getParame ...

  8. JSP中getParameter和getAttribute区别

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

  9. getParameter和getAttribute区别

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

随机推荐

  1. The Jaisalmer Desert Festival 2017/2/9

    原文 India's Golden City celebrates its culture with costumes(服装),crafts(工艺品) and camels One of the fe ...

  2. java 核心技术卷一笔记 6 .2接口 lambda 表达式 内部类

    6.2 接口实例 6.2.1 接口与回调 在java.swing包中有一个Timer类,可以使用它在到达给定的时间间隔时发出通告,假如程序中有一个时钟,就可以请求每秒钟获得一个通告,以便更新时钟的表盘 ...

  3. Python 元组、字典、集合操作总结

    元组 a=('a',) a=('a','b') 特点 有序 不可变,不可以修改元组的值,无法为元组增加或者删除元素 元组的创建 a=('a',) a=('a','b') tuple('abcd') 转 ...

  4. make 与makefile(会不会写 makefile,从一个侧面说明了一个人是否具备完成大型工程的能力。)

    跟我一起写 Makefile /**/ 陈皓 (CSDN) 概述 —— 什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了这个工作,但我觉 ...

  5. 多维的vector定义和初始化

    vector<vector<int> >vv(3, vector<int>(4));//这里,两个“>”间的空格是不可少的 将构造一个二维向量vv,它含有三个 ...

  6. blog.yiz96.com

    欢迎访问我的新博客 blog.yiz96.com

  7. HITICS || 2018大作业 程序人生 Hello's P2P

    摘  要 本文通过分析一个hello.c的完整的生命周期,从它开始被编译,到被汇编.链接.在进程中运行,讲解了Linux计算机系统执行一个程序的完整过程. 关键词:操作系统,进程,程序的生命周期 目 ...

  8. bootstrap历练实例: 基本胶囊式的导航菜单

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  9. [LUOGU] P1063 能量项链

    题目描述 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某个正整数.并且,对于相邻的两颗珠子,前一颗珠子的尾标记一定 ...

  10. mysql delete 表无法用别名

    delete from exam_paper_question_opt a WHERE a.OPTION_ID = 65630 and a.QUESTION_ID = 28656 AND a.EXAM ...