1. 程式人生 > >HttpServletRequest request 獲取header 和 body

HttpServletRequest request 獲取header 和 body

string () bsp body println span tel hole https

//獲取header

Enumeration headerNames = request.getHeaderNames();

while (headerNames.hasMoreElements()) {

String key = (String) headerNames.nextElement();

String value = request.getHeader(key);

System.out.println("=======車機返回Map:"+value+"========");

map.put(key, value);

}

//獲取body

BufferedReader br = request.getReader();

String str2, wholeStr = "";

while((str2 = br.readLine()) != null){

wholeStr += str2;

}

System.out.println(wholeStr);

HttpServletRequest request 獲取header 和 body