下面列出了怎么用org.springframework.boot.web.servlet.error.ErrorAttributes的API类实例代码及写法,或者点击链接到github查看源代码。
public DefaultErrorController(ErrorAttributes errorAttributes, ServerProperties properties) {
super(errorAttributes == null ? new DefaultErrorAttributes() : errorAttributes);
if (properties == null) {
errorProperties = new ErrorProperties();
errorProperties.setPath("/error");
} else {
this.errorProperties = properties.getError();
}
}
/**
* 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);
}
public CommonController(ThemeService themeService,
ErrorAttributes errorAttributes,
ServerProperties serverProperties,
OptionService optionService) {
super(errorAttributes);
this.themeService = themeService;
this.errorProperties = serverProperties.getError();
this.optionService = optionService;
}
public ErrorPageController(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
public ErrorEndpoint(ErrorAttributes errorAttributes) {
super(errorAttributes);
}
public ExceptionTranslator(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
public ExceptionTranslator(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
public ExceptionTranslator(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
public ErrorPageController(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
public ErrorPageController(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
/**
* 初始化ExceptionController
*
* @param errorAttributes
*/
@Autowired
public ErrorPagesController(ErrorAttributes errorAttributes) {
Assert.notNull(errorAttributes, "ErrorAttributes must not be null");
this.errorAttributes = errorAttributes;
}
@Autowired
public CustomErrorController(ErrorAttributes errorAttributes, ServerProperties serverProperties) {
super(errorAttributes);
this.errorProperties = serverProperties.getError();
}
@Autowired
public MyErrorController(ErrorAttributes errorAttributes, ServerProperties serverProperties) {
super(errorAttributes, serverProperties.getError());
}
public CustomBasicErrorController(ErrorAttributes errorAttributes) {
super(errorAttributes);
}
/**
* 初始化ExceptionController
*
* @param errorAttributes
*/
@Autowired
public ErrorPagesController(ErrorAttributes errorAttributes) {
Assert.notNull(errorAttributes, "ErrorAttributes must not be null");
this.errorAttributes = errorAttributes;
}
public CustomServletErrorController(ErrorAttributes errorAttributes,
ErrorProperties errorProperties,
List<ErrorViewResolver> resolvers) {
super(errorAttributes, errorProperties, resolvers);
}
@Autowired
public FinalController(ErrorAttributes errorAttributes, ServerProperties serverProperties) {
super(errorAttributes);
this.errorProperties = serverProperties.getError();
}
public ExceptionTranslator(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
public BladeErrorController(ErrorAttributes errorAttributes, ErrorProperties errorProperties) {
super(errorAttributes, errorProperties);
}
@Bean
@ConditionalOnMissingBean(value = ErrorAttributes.class, search = SearchStrategy.CURRENT)
public DefaultErrorAttributes errorAttributes() {
return new BladeErrorAttributes();
}
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController basicErrorController(ErrorAttributes errorAttributes) {
return new BladeErrorController(errorAttributes, serverProperties.getError());
}
public ErrorPageController(ErrorAttributes errorAttributes, List<ErrorViewResolver> errorViewResolvers) {
super(errorAttributes, errorViewResolvers);
}
/**
* 初始化ExceptionController
*
* @param errorAttributes
*/
@Autowired
public ErrorPagesController(ErrorAttributes errorAttributes) {
Assert.notNull(errorAttributes, "ErrorAttributes must not be null");
this.errorAttributes = errorAttributes;
}
@Bean
public ErrorAttributes errorAttributes() {
// override boot's DefaultErrorAttributes
return new SkipperErrorAttributes();
}
@Bean
public ErrorAttributes errorAttributes() {
// override boot's DefaultErrorAttributes
return new SkipperErrorAttributes();
}
public ErrorPageController(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
public ErrorPageController(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController jsonapiErrorController(ErrorAttributes errorAttributes) {
return new CrnkErrorController(errorAttributes, this.serverProperties.getError(), this.errorViewResolvers);
}
public CrnkErrorController(ErrorAttributes errorAttributes,
ErrorProperties errorProperties) {
super(errorAttributes, errorProperties);
}
public CrnkErrorController(ErrorAttributes errorAttributes,
ErrorProperties errorProperties,
List<ErrorViewResolver> errorViewResolvers) {
super(errorAttributes, errorProperties, errorViewResolvers);
}