Spring : Why should I still use @RequestBody when my class is already annotated with @RestController?

@RestController contains @ResponseBody so you do not need this any more.

But you still need the @RequestBody annotation, because the method you call for a POST request might contain more than one parameters, one of which is mapped to the request body, other parameters of the method might be PathVariables or for example a UriComponentsBuilder.

And to mark the parameter which is to be mapped to the request body, you need the annotation.

Tags:

Java

Rest

Spring