From 37290d023e12f6c83f3aa156110a66a6e7fe3b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Tue, 28 Feb 2023 19:52:02 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=B3=BB=E7=BB=9Furl=E5=AD=98=E5=82=A8=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/security/handler/AllUrlHandler.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/AllUrlHandler.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/AllUrlHandler.java index c1d14037..9542a55c 100644 --- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/AllUrlHandler.java +++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/AllUrlHandler.java @@ -8,10 +8,7 @@ import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.regex.Pattern; /** @@ -28,16 +25,18 @@ public class AllUrlHandler implements InitializingBean { @Override public void afterPropertiesSet() { + Set set = new HashSet<>(); RequestMappingHandlerMapping mapping = SpringUtils.getBean("requestMappingHandlerMapping", RequestMappingHandlerMapping.class); Map map = mapping.getHandlerMethods(); map.keySet().forEach(info -> { // 获取方法上边的注解 替代path variable 为 * Objects.requireNonNull(info.getPathPatternsCondition().getPatterns()) - .forEach(url -> urls.add(ReUtil.replaceAll(url.getPatternString(), PATTERN, "*"))); + .forEach(url -> set.add(ReUtil.replaceAll(url.getPatternString(), PATTERN, "*"))); // 获取类上边的注解, 替代path variable 为 * Objects.requireNonNull(info.getPathPatternsCondition().getPatterns()) - .forEach(url -> urls.add(ReUtil.replaceAll(url.getPatternString(), PATTERN, "*"))); + .forEach(url -> set.add(ReUtil.replaceAll(url.getPatternString(), PATTERN, "*"))); }); + urls.addAll(set); } }