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");