首页 > 编程语言 > 详细

springboot新版本(2.0.0+)自定义ErrorController中使用ErrorAttributes

时间:2019-02-15 23:59:26      阅读:770      评论:0      收藏:0      [点我收藏+]

2.0.0之前使用:

@Autowired
private ErrorAttributes errorAttributes;

private Map<String, Object> getErrorAttributes(HttpServletRequest request,
                                                   boolean includeStackTrace) {
        RequestAttributes requestAttributes = new ServletRequestAttributes(request);
        return this.errorAttributes.getErrorAttributes(requestAttributes,
                includeStackTrace);
    }

后续版本使用:

@Autowired
private ErrorAttributes errorAttributes;
private Map<String, Object> getErrorAttributes(HttpServletRequest request,
boolean includeStackTrace) {
ServletWebRequest servletWebRequest = new ServletWebRequest(request);
return this.errorAttributes.getErrorAttributes(servletWebRequest,
includeStackTrace);
}
 

 

springboot新版本(2.0.0+)自定义ErrorController中使用ErrorAttributes

原文:https://www.cnblogs.com/kingsonfu/p/10386376.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!