request 对象

request对象的常用方法:

setAttribute(String name,Object obj)    用于设置request中的属性及其属性值

getAttribute(String name)                        用于返回name指定的属性值,若不存在指定的属性值,就返回null

removeAttribute(String name)                 用于删除请求中的一个属性

getParameter(String name)                     用于获得客户端传送到服务器端的参数值

getParameterNames()                             用于获得客户端传送到服务器端的所有参数名字(Enumeration类的实例)

getParameterValues(String name)          用于获得指定参数的所有值

getCookie()                                              用于返回客户端的所有Cookie对象,结果是一个Cookie数组

getCharacterEncoding()                          返回请求中的字符的编码方式

getRequestURI()                                     用于获取发出请求字符串的客户端地址

getRemoteAddr()                                    用于回去客户端ip地址

getRemoteHost()                                    用于获取客户端名字 

getSession([Boolean create])                 用于返回和请求相关的session。create参数是可选的,true时,若客户端没有创建session,就创建一个人新的session。

getServerName()                                    用于获取服务器的名字

getServletPath()                                      用于获取客户端所请求的脚本文件的文件路径

getServerPort()                                       用于获取服务端的端口号

posted @ 2017-09-22 22:53  随心佩  阅读(119)  评论(0编辑  收藏  举报