Skip to content
Sharp

Spring Core · interview question

How can you configure a Spring Boot application to reject invalid requests at the controller level?

Multiple choiceHardchapter-9-curatedpremiumspring-corepersistence-and-validation
Choose one answer
Answer and explanation

Correct answer

D. Use @Valid and handle MethodArgumentNotValidException

Why

Using @Valid on method parameters in controllers ensures that validation occurs before entering the method body. Handling MethodArgumentNotValidException allows you to manage responses for validation errors.

Test yourself on Spring Core

A free test with instant, explained results. No account needed.

Start free test
All Spring Core questions →