@ResponseBody
You can use the @ResponseBody
annotation on a method to have the return serialized to the response body through an HttpMessageConverter. The following listing shows an example:
Java
@GetMapping("/accounts/{id}")
@ResponseBody
public Account handle() {
// ...
}
@ResponseBody
is also supported at the class level, in which case it is inherited by all controller methods. This is the effect of @RestController
, which is nothing more than a meta-annotation marked with @Controller
and @ResponseBody
.
You can use @ResponseBody
with reactive types. See