How to get request body although it didn't pass spring validation?

Viewed 35

By using

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>

and

org.springframework.validation.annotation.Validated on @RequestBody and involved POJO fields, spring (MVC) will help validate incoming request body automatically, and throw exception when the request body is invalid.

And by using @ExceptionHandler(value = MethodArgumentNotValidException.class), I will capture the exception and then return a more readable response body to frontend.

But by this way, I cannot get the whole request body. Is it possible to get the whole request body? Could you please help advise?

Thanks a lot.

0 Answers
Related