读取请求头header信息
public void list(HttpServletRequest request) { try{ Enumeration<String> headerNames = request.getHeaderNames(); while(headerNames.hasMoreElements()){ String name = headerNames.nextElement(); //根据名称获取请求头的值 String value = request.getHeader(name); System.out.println(name+"----"+value); } }catch (Exception ex){ System.out.println(ex.getMessage()); } }
打印效果: