From c857c90c8027f9933f57124ab3ef89079d30f564 Mon Sep 17 00:00:00 2001 From: wangys <3401275564@qq.com> Date: Fri, 13 Feb 2026 18:22:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8getServletPath?= =?UTF-8?q?=E8=A7=A3=E5=86=B3context-path=E5=AF=BC=E8=87=B4=E5=8F=AF?= =?UTF-8?q?=E9=80=89=E8=AE=A4=E8=AF=81=E6=AD=A3=E5=88=99=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/dora/interceptor/JwtAuthInterceptor.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/dora/interceptor/JwtAuthInterceptor.java b/src/main/java/com/dora/interceptor/JwtAuthInterceptor.java index c1aee64..7f89a3f 100644 --- a/src/main/java/com/dora/interceptor/JwtAuthInterceptor.java +++ b/src/main/java/com/dora/interceptor/JwtAuthInterceptor.java @@ -28,8 +28,9 @@ public class JwtAuthInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - String requestURI = request.getRequestURI(); - boolean isOptionalAuthPath = OPTIONAL_AUTH_PATTERN.matcher(requestURI).matches(); + // 使用 servletPath(不含context-path),与拦截器路径匹配一致 + String servletPath = request.getServletPath(); + boolean isOptionalAuthPath = OPTIONAL_AUTH_PATTERN.matcher(servletPath).matches(); // 从请求头获取token String authHeader = request.getHeader("Authorization");