Spring Boot 2系列(三十八):全局异常统一处理

  Spring Boot 在默认情况下,提供了 /error 映射来处理所有错误,在 Servlet 容器里注册了全局的错误页面(Whitelabel Error Page)并返回客户端。

  也可以自定义替换默认的异常处理, 通过实现 ErrorController 接口并注册为 Bean;或者添加 ErrorAttributes 类型的 Bean 来替换内容。

  通常情况下,都会自定义全局异常统一处理,返回统一的消息结构体,便于了解和快速定位问题,Spring 提供了 @ControllerAdvice 注解,非常好实现。

  Spring Boot 官方文档,错误处理:28.1.11 Error Handling

阅读更多
ustified-gallery > p > .gallery-item').length) { $('.justified-gallery > p > .gallery-item').unwrap(); } $('.justified-gallery').justifiedGallery(); } });