1.获取全部头信息:
//get request headers private Map<String, String> getHeadersInfo() { 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); } return map; }
2.获取某个头信息:
private String getHeader(String headerName) { return request.getHeader(headerName); }
参考:http://www.yihaomen.com/article/java/459.htm
时间: 2025-01-11 08:31:07