getParameter和getAttribute的区别是什么?
来源:互联网 发布:node.js 跨域访问 编辑:程序博客网 时间:2024/04/29 03:32
楼主xxmm(晓箫)2001-07-22 21:18:05 在 Java / Web 开发 提问
问题点数:20、回复次数:5Top
1 楼yelz(断弦)回复于 2001-07-22 21:55:46 得分 8
getParameter 返回上个页面提交得参数,getAttribute返回系统属性,不同jsp服务器可能不同。Top
2 楼xxmm(晓箫)回复于 2001-07-22 22:10:33 得分 0
系统属性指什么?能不能给一个例子?Top
3 楼muwenyi(咔咔)回复于 2002-02-10 13:17:46 得分 8
getParameter可以获得客户端传送给服务器端的参数值。
getAttribute可以得到由setAttribute设置的参数值,就相当于是使用getAttribute得到一个自己定义的参数,而不是从客户端得到的参数。我是这样理解的!Top
4 楼gzwrj(我无知,所以我有智慧.)回复于 2002-02-11 12:31:38 得分 2
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
Attributes can be set two ways. The servlet container may set attributes to make available custom information about a request. For example, for requests made using HTTPS, the attribute javax.servlet.request.X509Certificate can be used to retrieve information on the certificate of the client. Attributes can also be set programatically using setAttribute(java.lang.String, java.lang.Object). This allows information to be embedded into a request before a RequestDispatcher call.
Attribute names should follow the same conventions as package names. This specification reserves names matching java.*, javax.*, and sun.*.
Parameters:
name - a String specifying the name of the attribute
Returns:
an Object containing the value of the attribute, or null if the attribute does not exist
//
getParameter
public java.lang.String getParameter(java.lang.String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.
You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String).
If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by getParameterValues.
If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via getInputStream() or getReader() can interfere with the execution of this method.
Parameters:
name - a String specifying the name of the parameter
Returns:
a String representing the single value of the parameter
See Also:
getParameterValues(java.lang.String)
Top
5 楼armyshu(~!@#$%^&*)回复于 2002-02-19 11:41:06 得分 2
getParameter只能传递string类型的变量,getAttribute能传递vector!
- getParameter和getAttribute的区别是什么?
- getParameter和getAttribute的区别是什么?
- getParameter和getAttribute的区别是什么?
- getParameter和getAttribute的区别是什么?
- getParameter和getAttribute的区别是什么?
- Request中的getParameter和getAttribute的区别是什么?
- getAttribute 和 getParameter 的区别
- getAttribute 和 getParameter 的区别
- getParameter和getAttribute的区别
- getAttribute和getParameter的区别
- getAttribute和getParameter的区别
- getAttribute和getparameter的区别
- getAttribute和getParameter的区别
- getAttribute和getParameter的区别
- getAttribute和getParameter的区别
- getAttribute和getParameter的区别
- getAttribute和getParameter的区别
- getParameter和getAttribute的区别
- 在最近做一个高级查询时遇见的问题,javascript在动态的form里使用会出现问题
- Visual Basic .NET处理Excel表格全接触
- 吸取教训
- C#中使用split分割字符串的几种方法
- HTTP运行期与页面执行模型
- getParameter和getAttribute的区别是什么?
- sdfdsfdsf
- 修改Sun App Server的服务端口
- SWT实现窗口始终最前以及透明窗口
- 认识一下Attribute
- 关于ETH系统
- vs.net2005中使用利用cdo.message发送邮件(以asp.net/c#为例)
- 更新远程数据
- 在Eclipse上使用Hibernate