private HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes)(RequestContextHolder.currentRequestAttributes())).getRequest();
}
@SuppressWarnings("rawtypes")
private Map<String, String> getHeadersInfo() {
HttpServletRequest request = getHttpServletRequest();
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;
}
HttpServletRequest 获取header信息
最新推荐文章于 2024-06-11 21:34:01 发布