Request对象及常用方法

 

Object getAttribute(String name) 获得name的属性,若不存在,则返回null

Enumeration getAttributeNames() 返回一个枚举类型的包含request对象所有属性名称的集合

String getCharacterEncoding() 返回request请求体的字符编码

int getContentLength() 获得HTTP请求的长度

String getContentType() 获得客户端请求的MIME类型

String getContextPath() 获得上下文的路径,即当前Web应用的根目录

String getHeader(String name) 获得HTTP协议的文件头信息

ServletInputStream getInputStream() 得到请求体中一行的二进制流

String getMethod()获得哭护短请求的方法类型,一般为GET,POST等

String getParameter(String name) 获得指定参数name的参数值

Enumeration getParameterNames() 返回一个枚举类型的所有参数名称的集合

String[] getParameterValues(String name) 返回包含参数name的所有值的数组

String getProtocol() 返回请求所使用的协议及其版本

String getQueryString() 获得查询字符串,该字符串在客户端以GET方式向服务器传送

BufferedReader getReader() 以字符码的形式返回请求体

String getRemoteAddr() 返回客户端的IP地址

String getRemoteHost() 返回客户端的主机名

String getScheme() 返回请求所用的协议名称,例如HTTP,HTTPS,FTP等

String  getServerName() 获得服务器的名称,若没有设定服务器域名,则返回其IP地址

int getServerPort() 返回服务器的端口号

String getServletPath() 获得请求JSP页面的名称

boolean getSession() 返回和当前客户端请求相关联的HttpSession对象

boolean isSecure() 判断客户机是否以安全的访问方式访问服务器

void removeAttribute(String name)删除名称为name的request参数

void setAttribute(String name,Object obj) 设置一个名称为name的参数,并且其值为obj

void setCharacterEncoding(String enc) 设置请求信息的字符编码为enc

posted @ 2018-08-25 11:27  峰寒  阅读(887)  评论(0编辑  收藏  举报