- Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation taskA documentation task
Milestone
Description
Affects: <Spring Framework 6.1.8 and maybe other versions>
I write a simple demo below, I write a Controller with a handler method receiving a post request and consume a valid request body
@RestController class Controller { @PostMapping("/test") fun test(@RequestBody @Valid foo: Foo) { println(foo) } @ExceptionHandler(Exception::class) fun handleException(e: Exception) { println(e) } } data class Foo( @field:NotEmpty val name: String )Then I send a post request with this body to the application.
{ "name": "" }Check out the console and you can see a exception printed and it's type is WebExchangeBindException
But according to the spring document validation, it should throw a MethodArgumentNotValidException.

I also test this behavior in mvc and it's the expected exception.
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation taskA documentation task