springmvc 获取请求头信息

@PostMapping("/test/post")
    public void post(@RequestBody String params,
            @RequestHeader(required = false, value = "contentType") String contentType,
            @RequestHeader(required = false, value = "Accept") String Accept) {
        System.out.println("contentType:" + contentType);
        System.out.println("Accept:" + Accept);
        
        JSONObject json = JSONObject.parseObject(params);
        String userName = json.getString("username");
        System.out.println("userName:" + userName);
    }

 

posted @ 2018-09-12 22:18  huanggy  阅读(642)  评论(0编辑  收藏  举报