What is the role of the @ControllerAdvice annotation in a Spring Boot application?

  • To define request mapping for a controller.
  • To handle exceptions at the controller level.
  • To specify the HTTP request method.
  • To declare a controller class.
The @ControllerAdvice annotation in a Spring Boot application is used to handle exceptions at the controller level. It allows you to define global exception handling logic that can be applied across multiple controllers. This is particularly useful for defining consistent error handling behavior in your application. The other options do not accurately describe the role of @ControllerAdvice.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *