Why does @GetMapping have a 'consumes' attribute?

Viewed 113

In spring framework, @GetMapping doesn't have a body. But it has a 'consumes' attribute. So how does it use this attribute without a body?

example:

@GetMapping(value = "/methodA", consumes = "application/json")
1 Answers

You can read queryParam/Request HTTP header as below:

@GetMapping(value = "{URL}")
public ResponseEntity getMethod(@RequestParam("consumes") String consumes) {
        return ResponseEntity.ok().build();
}
Related