HttpServletRequest对象方法的用法
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- System.out.println("getRequestURL: "+request.getRequestURL());
- System.out.println("getRequestURI: "+request.getRequestURI());
- System.out.println("getQueryString: "+request.getQueryString());
- System.out.println("getRemoteAddr: "+request.getRemoteAddr());
- System.out.println("getRemoteHost: "+request.getRemoteHost());
- System.out.println("getRemotePort: "+request.getRemotePort());
- System.out.println("getRemoteUser: "+request.getRemoteUser());
- System.out.println("getLocalAddr: "+request.getLocalAddr());
- System.out.println("getLocalName: "+request.getLocalName());
- System.out.println("getLocalPort: "+request.getLocalPort());
- System.out.println("getMethod: "+request.getMethod());
- System.out.println("-------request.getParamterMap()-------");
- //得到请求的参数Map,注意map的value是String数组类型
- Map map = request.getParameterMap();
- Set<String> keySet = map.keySet();
- for (String key : keySet) {
- String[] values = (String[]) map.get(key);
- for (String value : values) {
- System.out.println(key+"="+value);
- }
- }
- System.out.println("--------request.getHeader()--------");
- //得到请求头的name集合
- Enumeration<String> em = request.getHeaderNames();
- while (em.hasMoreElements()) {
- String name = (String) em.nextElement();
- String value = request.getHeader(name);
- System.out.println(name+"="+value);
- }
- }
- getRequestURL: http://localhost:8080/RequestAndResponse/requestmethod
- getRequestURI: /RequestAndResponse/requestmethod
- getQueryString: name=sunjob&password=123456&password=haha
- getRemoteAddr: 127.0.0.1
- getRemoteHost: 127.0.0.1
- getRemotePort: 2374
- getRemoteUser: null
- getLocalAddr: 127.0.0.1
- getLocalName: localhost
- getLocalPort: 8080
- getMethod: GET
- -------request.getParamterMap()-------
- name=sunjob
- password=123456
- password=haha
- --------request.getHeader()--------
- host=localhost:8080
- user-agent=Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20100101 Firefox/17.0
- accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
- accept-language=zh-cn,en-us;q=0.8,zh;q=0.5,en;q=0.3
- accept-encoding=gzip, deflate
- connection=keep-alive
- cache-control=max-age=0
HttpServletRequest对象方法的用法的更多相关文章
- HttpServletRequest对象方法的用法(转)
原文地址:http://blog.csdn.net/xh16319/article/details/8450715 原文作者:ITSTAR 文章太赞,忍不住就想转..... 1. 获得客户机信息 ...
- HttpServletRequest和ServletRequest的区别以及HttpServletRequest对象方法的用法
HttpServletRequest和ServletRequest都是接口 HttpServletRequest继承自ServletRequest HttpServletRequest比Servlet ...
- ResquestInfoServlet类通过访问HttpServletRequest对象的各种方法来读取HTTP请求中的特定信息,并且把它们写入到HTML中
ResquestInfoServlet类通过访问HttpServletRequest对象的各种方法来读取HTTP请求中的特定信息,并且把它们写入到HTML中 ResquestInfoServlet.j ...
- java web学习总结(十) -------------------HttpServletRequest对象
一.HttpServletRequest介绍 HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中,通过这个对象 ...
- 学习zepto.js(对象方法)[4]
今天说说那一套获取元素集合的一些方法: ["children", "clone", "closest", "contents&qu ...
- 学习zepto.js(对象方法)[1]
zepto也是使用的链式操作,链式操作:函数返回调用函数的对象. 但并不是所有的对象方法都可以进行链式操作,举几个例子:.size(),.html()|.text()//不传参数的情况下; 若非特殊说 ...
- JavaWeb---总结(十)HttpServletRequest对象(一)
一.HttpServletRequest介绍 HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中,通过这个对象 ...
- javaweb学习总结(十)——HttpServletRequest对象(一)
一.HttpServletRequest介绍 HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中,通过这个对象 ...
- Oracle自定义数据类型 2 (调用对象方法)
调用对象方法 调用对象方法基于类型创建表后,就可以在查询中调用对象方法 A. 创建基于对象的表语法: create table <表名> of <对象类型>意义 ...
随机推荐
- setsockopt()用法(参数详细说明) recv、send的超时处理
源于recv send 阻塞和非阻塞 int setsockopt(SOCKET s,int level,int optname,const char* optval,int optlen); s(套 ...
- Java Web项目(Extjs)报错二
1.Java Web项目(Extjs)报错二 具体报错如下: usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ...
- vector 遍历
vector向量容器,是数组的一个泛化推广.实现了类似于数据结构中顺序表的操作. vector容器是一个模板类,可以存放任何类型的对象(但必须是同一类对象).vector对象可以在运行时高效地添加元素 ...
- Error:Error #2174
1.错误描述 Error:Error #2174 : 对于每个FileReference,每次只能执行一个下载.上载.加载或保存操作 2.错误原因 Flex中,在做单文件上传时,多次点击"上 ...
- CF198 div1 D - Iahub and Xors
简单说就是左边x,y按照奇偶分为四种对于答案的影响都是不相关的 #include<bits/stdc++.h> using namespace std; typedef long long ...
- Crash CodeForces - 417B
During the "Russian Code Cup" programming competition, the testing system stores all sent ...
- freemarker之list遍历(八)
1.设置数据源 /** * * @Title:student * @Description: * @param:@param name * @return: void * @throws */ pri ...
- mysql5.7安装教程
1, 下载mysql5.7的安装包mysql-5.7.17-winx64.zip,直接解压到安装目录 2, 进入mysql目录,在里面新建data目录 3, 修改mysql的my.ini文件,指定ba ...
- TensorLayer官方中文文档1.7.4:API – 数据预处理
所属分类:TensorLayer API - 数据预处理¶ 我们提供大量的数据增强及处理方法,使用 Numpy, Scipy, Threading 和 Queue. 不过,我们建议你直接使用 Tens ...
- Java汉字乱码问题
window->preferences->输入框输入"encod" 将text file encoding 从default改成other utf-8 同理,css,H ...