java 获取HttpRequest Header


RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
Enumeration e = request.getHeaderNames();
while (e.hasMoreElements()) {	
	String headerName = (String) e.nextElement();
	Enumeration<String> headerValues = request.getHeaders(headerName);
	while (headerValues.hasMoreElements()) {	
	    System.out.println(headerName + ":"+ headerValues.nextElement());
	}
}
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页