From cf66fc98fa2d149d8694487a8bb89cb2aff45f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E5=AD=90=E6=9D=8E=C2=B7De?= Date: Wed, 13 Apr 2022 17:31:50 +0800 Subject: [PATCH] Update TokenFilter.java --- .../template/gaea/business/filter/TokenFilter.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java index e6595b68..7411d5e7 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java @@ -41,6 +41,7 @@ import static com.anji.plus.gaea.constant.GaeaConstant.URL_REPLACEMENT; public class TokenFilter implements Filter { private static final Pattern PATTERN = Pattern.compile(".*().*"); private static final String USER_GUEST = "guest"; + @Value("${server.servlet.context-path:'/'}") private static final String SLASH = "/"; private AntPathMatcher antPathMatcher = new AntPathMatcher(); @@ -54,7 +55,6 @@ public class TokenFilter implements Filter { private List skipAuthenticateUrls; private Pattern skipAuthenticatePattern; - @Override public void init(FilterConfig filterConfig) throws ServletException { // 生成匹配正则,跳过token验证和权限验证的url @@ -74,8 +74,8 @@ public class TokenFilter implements Filter { return; } - if (SLASH.equals(uri)) { - response.sendRedirect("/index.html"); + if (SLASH.equals(uri) || SLASH.concat("/").equals(uri)) { + response.sendRedirect(SLASH + "/index.html"); return; } @@ -128,6 +128,7 @@ public class TokenFilter implements Filter { //判断接口权限 //请求路径 String requestUrl = request.getRequestURI(); + String servletPath = request.getServletPath(); String methodValue = request.getMethod(); //请求方法+#+请求路径 String urlKey = methodValue + GaeaConstant.URL_SPLIT + requestUrl;