java Spring AntRequestMatcher不匹配
我有一个关于蚂蚁匹配者的问题。我想创建一个不应用于特定URL的spring安全过滤器
要忽略此url,我正在使用AntPathRequestMatcher
:
AntPathRequestMatcher ignored = new AntPathRequestMatcher("**/MyURL/**");
实际上,我认为它会匹配所有包含“MyURL”的URL。但我错了
if(ignored.matches(httpReq)) {
log.info(ignored.toString()+" matches "+httpReq.getRequestURI());
} else {
log.info(ignored.toString()+" does not match "+httpReq.getRequestURI());
}
上面这一节给我带来了
Ant [pattern='**/myurl/**'] does not match /resource/MyURL/
当我提出请求时在日志中。模式should be case unsensitive
# 1 楼答案
正如@M. Deinum所写,您的模式必须以
/
开头,请参见AntPathMatcher:和AntPathMatcher#doMatch: