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

下面列出了怎么用org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController的API类实例代码及写法,或者点击链接到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);
}
 
 类方法
 同包方法