下面列出了org.springframework.boot.autoconfigure.web.ErrorAttributes#org.springframework.boot.autoconfigure.web.DefaultErrorAttributes 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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
ErrorAttributes errorAttributes() {
return new DefaultErrorAttributes();
}