From 7528a595fc97a187a15c29ebe03d22293a9aef6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E5=90=8D=E4=B8=B6=E5=B0=8F=E8=BE=88?= Date: Thu, 24 Jun 2021 08:30:47 +0000 Subject: [PATCH] =?UTF-8?q?update=20ruoyi-framework/src/main/java/com/ruoy?= =?UTF-8?q?i/framework/web/exception/GlobalExceptionHandler.java.=20?= =?UTF-8?q?=E5=BD=93=E8=AE=BF=E9=97=AE=E5=BC=82=E5=B8=B8=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E8=AF=B7=E6=B1=82URL=E7=9A=84?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=8C=E4=BE=BF=E4=BA=8E=E6=8E=92=E6=9F=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/exception/GlobalExceptionHandler.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java index 2ff357743..d268b143e 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java @@ -47,21 +47,23 @@ public class GlobalExceptionHandler /** * 请求方式不支持 */ - @ExceptionHandler({ HttpRequestMethodNotSupportedException.class }) - public AjaxResult handleException(HttpRequestMethodNotSupportedException e) - { - log.error(e.getMessage(), e); - return AjaxResult.error("不支持' " + e.getMethod() + "'请求"); + @ExceptionHandler({HttpRequestMethodNotSupportedException.class}) + public AjaxResult handleException(HttpRequestMethodNotSupportedException e, HttpServletRequest request) { + String requestURI = request.getRequestURI(); + String msg = String.format("访问的URL[%s]不支持%s请求", requestURI, e.getMethod()); + log.error(msg, e); + return AjaxResult.error(msg); } /** * 拦截未知的运行时异常 */ @ExceptionHandler(RuntimeException.class) - public AjaxResult notFount(RuntimeException e) - { - log.error("运行时异常:", e); - return AjaxResult.error("运行时异常:" + e.getMessage()); + public AjaxResult notFount(RuntimeException e, HttpServletRequest request) { + String requestURI = request.getRequestURI(); + String msg = String.format("访问的URL[%s]发生异常%s", requestURI, e.getMessage()); + log.error(msg, e); + return AjaxResult.error(msg); } /**