码迷,mamicode.com
首页 > 其他好文 > 详细

request获取各种信息

时间:2016-12-10 22:19:11      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:pre   shm   names   sign   head   get   nts   ati   key   

private Map<String, String> getHeadersInfo(HttpServletRequest request) {
Map<String, String> map = new HashMap<String, String>();
Enumeration headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String key = (String) headerNames.nextElement();
String value = request.getHeader(key);
map.put(key, value);
//System.out.println(key+":"+value);
}
return map;
}

private String getCookieId(HttpServletRequest request){
Cookie[] cookie = request.getCookies();
for (int i = 0; i < cookie.length; i++) {
Cookie cook = cookie[i];
System.out.println(cook.toString());
if(cook.getName().equalsIgnoreCase("eredg4.login.account")){ //获取键
System.out.println("account:"+cook.getValue().toString()); //获取值
}
}
return "";
}

request获取各种信息

标签:pre   shm   names   sign   head   get   nts   ati   key   

原文地址:http://www.cnblogs.com/sj521/p/6157953.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!