Request对象的主要方法有哪些?

 

 

方法

解释

setAttribute(String name,Object)

设置名字为name的request 的参数值

getAttribute(String name)

返回由name指定的属性值

getAttributeNames()

返回request 对象所有属性的名字集合,结果是一个枚举的实例

getCookies()

返回客户端的所有 Cookie 对象,结果是一个Cookie 数组

getCharacterEncoding()

返回请求中的字符编码方式 = getContentLength() :返回请求的 Body的长度

getParameter(String name)

获得客户端传送给服务器端的有 name指定的参数值

getRequestURI()

获取发出请求字符串的客户端地址

getRemoteAddr()

获取客户端的 IP 地址

getRemoteHost()

获取客户端的名字

getServletPath()

获取客户端所请求的脚本文件的路径

getServerPort()

获取服务器的端口号

removeAttribute(String name)

删除请求中的一个属性

原文地址:https://www.cnblogs.com/lixuze/p/14248543.html