如果SpringBoot 2.xxx版本,会发现下面的方法已经不能用了
getErrorAttributes(RequestAttributes requestAttributes, boolean includ)
在springboot 2.xxx版本,用下面方法来替代
getErrorAttributes(WebRequest webRequest, ErrorAttributeOptions options)
@Override
public Map<String, Object> getErrorAttributes(WebRequest webRequest, ErrorAttributeOptions options) {
Map<String, Object> map = super.getErrorAttributes(webRequest, options);
map.put("company","atguigu");
//我们的异常处理器携带的数据
Map<String,Object> ext = (Map<String,Object>)webRequest.getAttribute("ext", 0);
System.out.println(map.put("ext", ext));
return map;
}