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

  1. attribute与parameter区别(转)

    文章转自http://blog.csdn.net/saygoodbyetoyou/article/details/9006001 request.getParameter取得Web客户端到web服务端 ...

  2. Request中Attribute 和 Parameter 的区别

    Attribute 和 Parameter 的区别 (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方法 (2)当两个Web组件之间为 ...

  3. Attribute 和 Parameter 的区别

    Attribute 和 Parameter 的区别 (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方法 (2)当两个Web组件之间为 ...

  4. 参数(parameter)和属性(Attribute)的区别

    参数(parameter)和属性(Attribute)的区别 区别: 来源不同: 参数(parameter)是从客户端(浏览器)中由用户提供的,若是GET方法是从URL中 提供的,若是POST方法是从 ...

  5. [attribute|=value]和[attribute^=value]选择器区别

    1.[attribute|=value] [attribute|=value]选择器说明:http://www.w3school.com.cn/cssref/selector_attribute_va ...

  6. jQuery的attr与prop,attribute和property区别

    jQuery1.6中新添加了一个prop方法,看起来和用起来都和attr方法一样,这两个方法有什么区别呢?这要从HTMl 的attribute与property区别说起,attr与prop正是这两个东 ...

  7. attribute与property区别总结

    在前阵子看JQuery源码中,attr()的简单理解是调用了element.getAttribute()和element.setAttribute()方法,removeAttr()简单而言是调用ele ...

  8. CSS选择器[attribute | = value] 和 [attribute ^ = value]的区别

    前言 首先你需要知道[attribute | = value] 和 [attribute ^ = value] 分别是什么? ①:[attribute | = value] ②:[attribute ...

  9. parameter与attribute的使用场合(转载自草原和大树)

    Attribute 和 Parameter 的区别 (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方法 (2)当两个Web组件之间为 ...

随机推荐

  1. target="_blank"

    target="_blank":出现在<a target="_blank" href="http://">中,在开发中,在一个系 ...

  2. DataRead 和DataSet区别

    dataset表示一个数据集,是数据在内存中的缓存. 可以包括多个表DatSet 连接数据库时是非面向连接的.把表全部读到Sql中的缓冲池,并断开于数据库的连接 datareader 连接数据库时是面 ...

  3. C# Winform学习--- 实现石头剪刀布的游戏

    本文使用winform实现简单的石头剪刀布的游戏,主要实现,电脑随机出拳,玩家手动点击出拳:实现简易背景图片3秒切换:简易统计信息. 1.效果图 2.实现代码 新建一个windows窗体程序,用数字1 ...

  4. Miller_Rabin素数测试

    #include<iostream> #include<cmath> #include<cstdio> #include<cstring> #inclu ...

  5. 伸缩盒 Flexible Box(旧)

    box-orient  box-pack    box-align  box-flex   box-flex-group  box-ordinal-group   box-direction  box ...

  6. 如何查看SharePoint未知错误的详细信息

    在sharepoint 开发的时候,需要查看具体的sharepoint报错信息需要在配置文件中配置如下 通过下面方法就可以直接在出错页面查看错误信息.修改Web应用程序根目录上的Web.config文 ...

  7. Spring.Scheduling.Quartz 作业的应用(定时任务和循环触发任务)

    .定时任务的实现,比如有个任务是要晚上2点10分的时候要去触发的,先定义这个任务类RskBookFilterInitDiningService.cs,这里其实有两种实现,一种是需要继承QuartzJo ...

  8. mac iterm2配置

    iterm2的配置分为如下几个部分: 1. 字体大小的配置: iTerm->Preferences->Profiles->Text->Regular Font: 我在这里设置成 ...

  9. ASP.NET c# textbox 正则表达式 文本框只允许输入数字(验证控件RegularExpressionValidator )

    <input type="text" name="test" onKeyUp="test1.value=(this.value=this.val ...

  10. UIScrollView

    1.PPT介绍什么是UIScrollView 2.新建项目“大图片展示” * 尽量用storyboard,减少代码 * 设置contentSize属性 * 取消autolayout * 说明frame ...