简介
Springboot项目在启动的时候,会自动装配一些常用的配置类(xxxAuoConfiguration),今天就来看一下和error有关的自动装配
ErrorMvcAutoConfiguration
1 |
|
ErrorMvcAutoConfiguration中有以下的组件:
DefaultErrorAttributes
1 |
|
DefaultErrorAttributes中有个getErrorAttributes方法,是用于获取错误信息的
1 |
|
ErrorPageCustomizer
1 |
|
其中主要有个registerErrorPages,这就是获取错误页面路径的方法。会返回一个
path=/error,所以springboot默认会跳转到/error
1 |
|
DefaultErrorViewResolver
1 |
|
默认的错误页面解析器,其中的主要方法
1 |
|
WhitelabelErrorViewConfiguration
1 |
|
这个就是默认的白页,当没有自定义的error页面时,springboot默认会使用白页。如果在template中存在了error.html,就不会注册这个bean
BasicErrorController
1 |
|
BasicErrorController是默认处理/error请求的。其中有两个主要的方法
1 |
|