编程语言
首页 > 编程语言> > java读取前端请求头

java读取前端请求头

作者:互联网

读取请求头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());
       }
   }

打印效果:

 

标签:java,读取,前端,request,System,String,out,headerNames,name
来源: https://www.cnblogs.com/ckfuture/p/15233590.html