org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController源码实例Demo

类org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController源码实例Demo

下面列出了org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * Registers a custom {@link ErrorController} to change the default error handling approach.
 *
 * @param errorAttributes    Will be used to enrich error responses.
 * @param serverProperties   Will be used to access error related configurations.
 * @param errorViewResolvers All possible view resolvers to render the whitelabel error page.
 * @return The custom error controller instance.
 */
@Bean
@ConditionalOnBean(WebErrorHandlers.class)
@ConditionalOnMissingBean(ErrorController.class)
public BasicErrorController customErrorController(ErrorAttributes errorAttributes,
                                             ServerProperties serverProperties,
                                             ObjectProvider<ErrorViewResolver> errorViewResolvers) {
    List<ErrorViewResolver> resolvers = errorViewResolvers.orderedStream().collect(toList());
    return new CustomServletErrorController(errorAttributes, serverProperties.getError(), resolvers);
}
 
源代码2 项目: Aooms   文件: AoomsConfiguration.java
@Bean
public BasicErrorController basicErrorController(){
    return new AoomsGlobalErrorController(serverProperties);
}
 
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController basicErrorController(ErrorAttributes errorAttributes) {
	return new BladeErrorController(errorAttributes, serverProperties.getError());
}
 
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController jsonapiErrorController(ErrorAttributes errorAttributes) {
	return new CrnkErrorController(errorAttributes, this.serverProperties.getError(), this.errorViewResolvers);
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 类方法
 同包方法