CommonServletUtil.getRequest().getRequestURL()获取到的请求地址会是/error

pull/214/head
peng.miao 6 months ago
parent 0806f5d890
commit 1a9550e528

@ -41,10 +41,10 @@ public class GlobalErrorAttributesHandler extends DefaultErrorAttributes {
// 获取其状态码 // 获取其状态码
Object status = defaultErrorAttributes.get("status"); Object status = defaultErrorAttributes.get("status");
Object path = defaultErrorAttributes.get("path");
if (ObjectUtil.isNotEmpty(status)) { if (ObjectUtil.isNotEmpty(status)) {
// 如果其为404则处理 // 如果其为404则处理
if (HttpStatus.HTTP_NOT_FOUND == Convert.toInt(status)) { if (HttpStatus.HTTP_NOT_FOUND == Convert.toInt(status)) {
Object path = defaultErrorAttributes.get("path");
if(ObjectUtil.isNotEmpty(path)) { if(ObjectUtil.isNotEmpty(path)) {
return BeanUtil.beanToMap(CommonResult.get(HttpStatus.HTTP_NOT_FOUND, "路径不存在,请求地址:" + return BeanUtil.beanToMap(CommonResult.get(HttpStatus.HTTP_NOT_FOUND, "路径不存在,请求地址:" +
Convert.toStr(path), null)); Convert.toStr(path), null));
@ -53,7 +53,7 @@ public class GlobalErrorAttributesHandler extends DefaultErrorAttributes {
} }
} else { } else {
return BeanUtil.beanToMap(CommonResult.get(HttpStatus.HTTP_INTERNAL_ERROR, "服务器异常,请求地址:" + return BeanUtil.beanToMap(CommonResult.get(HttpStatus.HTTP_INTERNAL_ERROR, "服务器异常,请求地址:" +
CommonServletUtil.getRequest().getRequestURL(), null)); Convert.toStr(path), null));
} }
} }

Loading…
Cancel
Save