From 287effdc6dc076877b55eee8549c2063605820a4 Mon Sep 17 00:00:00 2001 From: AprilWind <2100166581@qq.com> Date: Tue, 2 Dec 2025 19:02:21 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=A2=9E=E5=8A=A0SpEL=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E8=A7=A3=E6=9E=90=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/web/handler/GlobalExceptionHandler.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java index 86363ed6e..7e615b404 100644 --- a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java +++ b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java @@ -15,6 +15,7 @@ import org.dromara.common.core.exception.base.BaseException; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.json.utils.JsonUtils; import org.springframework.context.support.DefaultMessageSourceResolvable; +import org.springframework.expression.ExpressionException; import org.springframework.expression.spel.SpelEvaluationException; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.validation.BindException; @@ -44,7 +45,7 @@ public class GlobalExceptionHandler { */ @ExceptionHandler(HttpRequestMethodNotSupportedException.class) public R handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, - HttpServletRequest request) { + HttpServletRequest request) { String requestURI = request.getRequestURI(); log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod()); return R.fail(HttpStatus.HTTP_BAD_METHOD, e.getMessage()); @@ -212,13 +213,12 @@ public class GlobalExceptionHandler { } /** - * SpEL 表达式解析异常 + * SpEL 表达式相关异常 */ - @ExceptionHandler(SpelEvaluationException.class) - public R handleSpelEvaluationException(SpelEvaluationException e, HttpServletRequest request) { - String requestURI = request.getRequestURI(); - log.error("请求地址'{}',SpEL解析异常: {}", requestURI, e.getMessage()); - return R.fail(HttpStatus.HTTP_INTERNAL_ERROR, "[SpEL解析失败] " + e.getMessage()); + @ExceptionHandler(ExpressionException.class) + public R handleSpelException(ExpressionException e, HttpServletRequest request) { + log.error("请求地址'{}',SpEL解析异常: {}", request.getRequestURI(), e.getMessage()); + return R.fail(HttpStatus.HTTP_INTERNAL_ERROR, "SpEL解析失败:" + e.getMessage()); } }