Bird
0
0

What does the @Validated annotation do when placed on a Spring Boot controller class?

easy📝 Conceptual Q1 of 15
Spring Boot - Request and Response Handling
What does the @Validated annotation do when placed on a Spring Boot controller class?
AIt disables all validation for the controller methods.
BIt automatically logs validation errors without throwing exceptions.
CIt enables validation of method parameters annotated with validation annotations.
DIt converts validation errors into HTTP 500 server errors.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of @Validated on controller

    The @Validated annotation activates validation for method parameters annotated with validation constraints in the controller.
  2. Step 2: Check behavior on validation failure

    If validation fails, Spring Boot throws a MethodArgumentNotValidException or similar, not disabling validation or logging silently.
  3. Final Answer:

    It enables validation of method parameters annotated with validation annotations. -> Option C
  4. Quick Check:

    @Validated activates validation = B [OK]
Quick Trick: Use @Validated to activate method parameter validation [OK]
Common Mistakes:
  • Thinking @Validated disables validation
  • Assuming it logs errors without exceptions
  • Confusing it with error handling annotations

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes