获取单个Header
示例:
@PostMapping(value = "/tree")
public String organTree(@RequestHeader("appKey") String appKey) {
return "";
}
获取所有Header
示例:
@GetMapping("/listHeaders")
public ResponseEntity<String> listAllHeaders(@RequestHeader Map<String, String> headers) {
headers.forEach((key, value) -> {
LOG.info(String.format("Header '%s' = %s", key, value));
});
return new ResponseEntity<String>(String.format("Listed %d headers", headers.size()), HttpStatus.OK);
}
参考: