java URl 匹配器
今天晚上空了就顺手写了一个Spring自带路径的通配符匹配的实现,个人感觉Spring可玩性还是很多,今后有空就总结一些分享给大家
/**
-
URL 匹配器
-
@author qijiahai
-
@version dw-spring-cloud-shop v2.0
-
@date 2020/6/18 23:01
*/
public class UrlMatch {/**
- URl匹配,可模糊匹配
- @param patternUrl
- @param requestUrl
- @return
*/
public static boolean match(String patternUrl, String requestUrl) {
if (StringUtils.isEmpty(patternUrl) || StringUtils.isEmpty(requestUrl)) {
return false;
}
PathMatcher matcher = new AntPathMatcher();
return matcher.match(patternUrl, requestUrl);
}
}
可以当作String模糊匹配器,具体怎么用就看大家的业务了