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

pull/214/head
peng.miao 2024-05-27 16:14:26 +08:00
parent 0806f5d890
commit 1a9550e528
1 changed files with 2 additions and 2 deletions

View File

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