标签:lse 异常处理 none spring att vat 打印 int includes
在spring boot 2.2 中 默认状态为status 999
private void addStatus(Map<String, Object> errorAttributes, RequestAttributes requestAttributes) { Integer status = (Integer)this.getAttribute(requestAttributes, "javax.servlet.error.status_code"); if (status == null) { errorAttributes.put("status", 999); errorAttributes.put("error", "None"); } else { errorAttributes.put("status", status); try { errorAttributes.put("error", HttpStatus.valueOf(status).getReasonPhrase()); } catch (Exception var5) { errorAttributes.put("error", "Http Status " + status); } } }
如果我们自定义异常信息, 默认会打印一串trace信息,但是我们不需要
@Component public class AppErrorAttribute extends DefaultErrorAttributes { @Override public Map<String, Object> getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) { Map<String, Object> map = super.getErrorAttributes(webRequest, includeStackTrace); // 这里参数可以配置为false map.put("url","www.blogdgw.com"); map.put("ext",webRequest.getAttribute("ext",0)); // 禁止trace 覆盖 //map.put("trace",""); return map; } }
标签:lse 异常处理 none spring att vat 打印 int includes
原文地址:https://www.cnblogs.com/dgwblog/p/11978663.html