spring 通配符 匹配

    作了一个权限管理系统,须要经过通配符来过滤请求url,在网上找了半天没有找到,后来想到spring自己就带有这个功能,经过查询最终找到了方法。使用该方法,须要引入spring-core包java

 

@Test
	public void regexSpringTest() {
		AntPathMatcher matcher = new AntPathMatcher();
		String path = "/test/a/b";
		String pattern = "/test/**";
		boolean isMatch=matcher.match(pattern, path);
		logger.info("isMatch:{}", isMatch);
	}

 

注意:spring

  • 加载路径中的通配符:?(匹配单个字符),*(匹配除/外任意字符)、**/(匹配任意多个目录)
相关文章
相关标签/搜索