首页 > 其他分享 >请求对象HttpServletRequest——获取请求头信息的方法

请求对象HttpServletRequest——获取请求头信息的方法

时间:2023-03-22 15:57:26浏览次数:50  
标签:HttpServletRequest 请求 req System value 获取 String names out

 

 

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String connection = req.getHeader("connection");
        System.out.println(connection);

        Enumeration<String> values = req.getHeaders("accept-encoding");
        while (values.hasMoreElements()) {
            String value = values.nextElement();
            System.out.println(value);
        }

        Enumeration<String> names = req.getHeaderNames();
        while (names.hasMoreElements()) {
            String value = req.getHeader(names.nextElement());
            System.out.println(value);
        }
    }

 

标签:HttpServletRequest,请求,req,System,value,获取,String,names,out
From: https://www.cnblogs.com/weiduaini/p/17244315.html

相关文章