下面列出了org.springframework.boot.autoconfigure.web.ErrorController#org.springframework.boot.autoconfigure.web.ErrorAttributes 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public SmartGlobalErrorController(ErrorAttributes errorAttributes, ErrorControllerProperties config,
CompositeErrorConfiguringAdapter adapter) {
super(errorAttributes);
notNull(config, "ErrorControllerProperties must not be null.");
notNull(adapter, "CompositeErrorConfiguringAdapter must not be null.");
this.config = config;
this.adapter = adapter;
}
/**
* 抄的是{@link ErrorMvcAutoConfiguration#basicErrorController(ErrorAttributes)}
*
* @param errorAttributes
* @return
*/
@Bean
public CustomErrorController customErrorController(ErrorAttributes errorAttributes) {
return new CustomErrorController(
errorAttributes,
this.serverProperties.getError(),
this.errorViewResolvers
);
}
@Bean
public ErrorAttributes customizeErrorResponseAttributes() {
return new DefaultErrorAttributes(){
@Override
public Map<String, Object> getErrorAttributes(RequestAttributes requestAttributes, boolean includeStackTrace) {
Map<String, Object> errorAttributes = super.getErrorAttributes(requestAttributes, includeStackTrace);
errorAttributes.remove("timestamp");
errorAttributes.remove("exception");
return errorAttributes;
}
};
}
@Bean
public SmartGlobalErrorController smartGlobalErrorController(ErrorAttributes errorAttrs,
CompositeErrorConfiguringAdapter adapter, ErrorControllerProperties config) {
return new SmartGlobalErrorController(errorAttrs, config, adapter);
}
public ErrorController(HttpServletRequest request, ErrorAttributes errorAttributes, ServerProperties serverProperties) {
Assert.notNull(errorAttributes, "ErrorAttributes must not be null");
this.errorAttributes = errorAttributes;
this.serverProperties = serverProperties;
this.request = request;
}
@Autowired
public ConsoleIndex(ErrorAttributes errorAttributes) {
super(errorAttributes);
}
public CrnkErrorController(ErrorAttributes errorAttributes,
ErrorProperties errorProperties) {
super(errorAttributes, errorProperties);
}
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController jsonapiErrorController(ErrorAttributes errorAttributes) {
return new CrnkErrorController(errorAttributes, this.serverProperties.getError(), this.errorViewResolvers);
}
public CustomErrorController(ErrorAttributes errorAttributes,
ErrorProperties errorProperties) {
super(errorAttributes, errorProperties);
}
public CustomErrorController(ErrorAttributes errorAttributes,
ErrorProperties errorProperties,
List<ErrorViewResolver> errorViewResolvers) {
super(errorAttributes, errorProperties, errorViewResolvers);
}
@Bean
public ErrorAttributes errorAttributes() {
return new CustomErrorAttributes();
}
@Bean
ErrorAttributes errorAttributes() {
return new DefaultErrorAttributes();
}
@Bean
@ConditionalOnMissingBean(DataResultErrorController.class)
public ErrorController dataResultErrorController(ErrorAttributes errorAttributes, ServerProperties serverProperties){
return new DataResultErrorController(errorAttributes, serverProperties.getError(),
this.errorViewResolvers);
}
public DataResultErrorController(ErrorAttributes errorAttributes, ErrorProperties errorProperties) {
super(errorAttributes, errorProperties);
}
public DataResultErrorController(ErrorAttributes errorAttributes,
ErrorProperties errorProperties,
List<ErrorViewResolver> errorViewResolvers) {
super(errorAttributes, errorProperties, errorViewResolvers);
}
public CrnkErrorController(ErrorAttributes errorAttributes,
ErrorProperties errorProperties,
List<ErrorViewResolver> errorViewResolvers) {
super(errorAttributes, errorProperties, errorViewResolvers);
}
/**
* Controller for the Error Controller
*
* @param errorAttributes
*/
public WxErrorController(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}