For the latest stable version, please use Spring Framework 6.2.5!

@RequestBody

You can use the @RequestBody annotation to have the request body read and deserialized into an Object through an HttpMessageReader. The following example uses a @RequestBody argument:

@PostMapping("/accounts")
public void handle(@RequestBody Account account) {
	// ...
}

Unlike Spring MVC, in WebFlux, the @RequestBody method argument supports reactive types and fully non-blocking reading and (client-to-server) streaming.

@PostMapping("/accounts")
public void handle(@RequestBody Mono<Account> account) {
	// ...
}

You can use the HTTP message codecs option of the WebFlux Config to configure or customize message readers.

You can use @RequestBody in combination with jakarta.validation.Valid or Spring’s @Validated annotation, which causes Standard Bean Validation to be applied. Validation errors cause a WebExchangeBindException, which results in a 400 (BAD_REQUEST) response. The exception contains a BindingResult with error details and can be handled in the controller method by declaring the argument with an async wrapper and then using error related operators:

@PostMapping("/accounts")
public void handle(@Valid @RequestBody Mono<Account> account) {
	// use one of the onError* operators...
}