【springboot】getErrorAttributes(RequestAttributes requestAttributes, boolean includ)不能用?

如果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;
    }

猜你喜欢

转载自blog.csdn.net/Black_Customer/article/details/107731775
今日推荐