获取请求头数据:request方法
(*重要)String getHeader(String name):通过请求头的名称获取请求头的值
Enumeration<String> getHeaderNames():获取所有的请求头名称
1 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 2 //获取所有请求头名称 3 Enumeration<String> headerNames = request.getHeaderNames(); 4 while (headerNames.hasMoreElements()) { 5 String name = headerNames.nextElement(); 6 //根据名称获取请求头的值 7 String value = request.getHeader(name); 8 System.out.println(name+"---"+value); 9 } 10 11 }