In Spring Boot, which annotation is used to handle exceptions at the controller level?

  • @ExceptionHandler
  • @ControllerAdvice
  • @RestController
  • @RequestMapping
In Spring Boot, the @ExceptionHandler annotation is used to handle exceptions at the controller level. This annotation allows you to define methods within a controller that can handle specific exceptions thrown by that controller. The other options, such as @ControllerAdvice, @RestController, and @RequestMapping, have different roles and are not used for handling exceptions directly at the controller level.
Add your answer
Loading...

Leave a comment

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