SpringBoot 实践系列-Filter 中的异常处理和 Controller 中的异常处理

本篇主要是记录如何使用 SpringBoot 所提供的 ErrorController 这个接口能力;其内置了一个 BasicErrorController 对异常进行统一的处理,当在 Controller 发生异常的时候会自动把请求 forward 到 /error 这个请求 path 下(/error 是 SpringBoot 提供的一个默认的mapping)。BasicErrorController 提供两种返回错误:1、页面返回;2、json 返回。

阅读更多