From caa75004fb078eb9da78faa0cb9665825e64514f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 20 Aug 2025 13:22:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E3=80=90framework=20=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E3=80=91=E5=85=BC=E5=AE=B9=20SpringBoot=202.X=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84=20API=20=E5=8A=A0=E8=A7=A3=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/encrypt/core/filter/ApiEncryptFilter.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptFilter.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptFilter.java index 1216ffeb6..126a76a01 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptFilter.java @@ -23,6 +23,7 @@ import org.springframework.http.HttpMethod; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerExecutionChain; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; +import org.springframework.web.util.ServletRequestPathUtils; import java.io.IOException; @@ -131,6 +132,12 @@ public class ApiEncryptFilter extends ApiRequestFilter { @SuppressWarnings("PatternVariableCanBeUsed") private ApiEncrypt getApiEncrypt(HttpServletRequest request) { try { + // 特殊:兼容 SpringBoot 2.X 版本会报错的问题 https://t.zsxq.com/kqyiB + if (!ServletRequestPathUtils.hasParsedRequestPath(request)) { + ServletRequestPathUtils.parseAndCache(request); + } + + // 解析 @ApiEncrypt 注解 HandlerExecutionChain mappingHandler = requestMappingHandlerMapping.getHandler(request); if (mappingHandler == null) { return null;