Spring @ControllerAdvice vs ErrorController

后端 未结 1 1143
逝去的感伤
逝去的感伤 2021-02-14 07:13

In my REST service app, I am planning to create a @ControllerAdvice class to catch controller thrown exceptions and return ResponseEntity objects accor

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-14 07:37

    An implementation of the ErrorController is used to provide a custom whitelabel error page.

    A class annotated with @ControllerAdvise is used to add a global exception handling logic for the whole application. Thus, more than one controller in your application.

    If in your application there is no mapping found for a request or page then spring will fallback to the 'whitelabel error page'. And in this case it will be the custom implementation of ErrorController

    0 讨论(0)
提交回复
热议问题