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 <对象类型>意义 ...
随机推荐
- 基于Jenkins+Git+Gradle的Android持续集成
本文参考了: http://my.oschina.net/uboluo/blog/157483 http://java.dzone.com/articles/automating-continuous ...
- sdl的缩放问题
SDL是一种既是开源的,也是跨平台的多媒体开发包,在各种平台上应用很广,经常和FFMPEG等解码器同时使用.对于在windows mobile等缺乏通用播放器的平台来说,是一种很好的选择.网上很多代码 ...
- R语言数据集合并、数据增减、不等长合并
每每以为攀得众山小,可.每每又切实来到起点,大牛们,缓缓脚步来俺笔记葩分享一下吧,please~ --------------------------- 数据选取与简单操作: which 返回一个向量 ...
- Struts2实现文件上传报错(二)
1.具体报错如下 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -he ...
- MySQL插入数据时插入无效的列
1.错误描述 com.mysql.jdbc.exception:jdbc4.MySQLSyntaxErrorException:Unknown column 'man' in 'field list' ...
- directX枚举系统设备类
void CSysEnumDlg::DisplayFullCategorySet(void){ USES_CONVERSION; HRESULT hr; IEnumMoniker * ...
- VS2010编译VS2008工程时,LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
1.问题 电脑上同时安装了VS2008,VS2010,使用VS2010编译VS2008建立的工程,或者,VS2010创建新的工程.编译时,出现以下链接错误: LINK : fatal error LN ...
- Android动态类生成预加载-dexmaker使用
一.dexmaker简单介绍 dexmaker是运行在Android Dalvik VM上,利用Java编写,来动态生成DEX字节码的API.如果读者了解AOP编程的话,应该听说过cglib or A ...
- 【BZOJ2160】拉拉队排练(回文树)
[BZOJ2160]拉拉队排练(回文树) 题面 BZOJ 题解 看着题目, 直接构建回文树 求出每个回文串的出现次数 直接按照长度\(sort\)一下就行了 然后快速幂算一下答案就出来了 这题貌似可以 ...
- Frogger POJ - 2253
题意 给你n个点,1为起点,2为终点,要求所有1到2所有路径中每条路径上最大值的最小值. 思路 不想打最短路 跑一边最小生成树,再扫一遍1到2的路径,取最大值即可 注意g++要用%f输出!!! 常数巨 ...