private List<String> excludePathPatterns = Arrays.asList(
            "/login/001",
            "/v2/api-docs",
            "/swagger-resources/**",
            "/swagger-ui.html",
            "/webjars/**",
            "/**/order"
    );

    private List<String> checkPath = Arrays.asList(
            "/login/001",
            "/v2/api-docs",
            "/swagger-resources/xxx",
            "/swagger-ui.html",
            "/webjars/11213",
            "/xx/order"
    );

    private boolean isExcluded(String requestURI) {
        for (String pattern : excludePathPatterns) {
            String regex = pattern.replace("**", ".*").replace("/*", "/[^/]*");
            if (requestURI.matches(regex)) {
                return true; 
            }
        }
        return false; 
    }

    @Test
    public void testNam11e()
    {
        for (String excludePathPattern : checkPath) {
            boolean excluded = isExcluded(excludePathPattern);
            System.err.println(excluded);
        }
    }

 

posted on 2024-12-10 10:37  lshan  阅读(3)  评论(0编辑  收藏  举报