PathMatcher matcher = new AntPathMatcher() 路径匹配用法

基于正则表达式匹配路径。

import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;

PathMatcher matcher = new AntPathMatcher();
matcher.match("/**/login/**", uri)

实例:

System.out.println(matcher.match("/login/**", "/login/into"));

true
System.out.println(matcher.match("/**/login/**", "/login/into"));

true
System.out.println(matcher.match("/**/login/**", "/xxx/login/into"));

true
System.out.println(matcher.match("/login/**", "/xxx/login"));

false

反正和那些登录拦截器的拦截方式一样

猜你喜欢

转载自blog.csdn.net/qq_39648029/article/details/106018433