[英]Regex doesn't match antMatcher URL pattern
I am trying to ignore a url from authentication I've tried multiple different patterns but java doesn't seem to be able to recognize them.我试图忽略身份验证中的 url 我尝试了多种不同的模式,但 java 似乎无法识别它们。 My configure looks like this:
我的配置是这样的:
@Override
public void configure(WebSecurity web) throws Exception {
super.configure(web);
web.ignoring().antMatchers(
"/api/pies.*active=true");
}
the string I want to match and have spring security ignore is something like this: http://"someEnv"/"somePath"/api/pies?active=true我想匹配并让 spring 安全忽略的字符串是这样的:http://"someEnv"/"somePath"/api/pies?active=true
however no matter what wildcard combo I try it doesn't match.但是无论我尝试什么通配符组合,它都不匹配。 The match has to have ?active=true
匹配必须有 ?active=true
Below is the method def:下面是方法定义:
@GetMapping()
public ResponseEntity<List<PieResponseDto>> getPies(@RequestParam(name = "active") Boolean active)
below is the class def:下面是类定义:
@RestController
@RequestMapping(path = "/api/pies", produces = MediaType.APPLICATION_JSON_VALUE)
Use .regexMatchers
instead of .antMatchers
and then try this regex:使用
.regexMatchers
而不是.antMatchers
然后试试这个正则表达式:
^[a-zA-Z:\/.]*pies\?active=true$
There are plenty of online tools for regex expressions.有很多用于正则表达式的在线工具。 You can try for example this one: online regex tester
您可以尝试例如这个:在线正则表达式测试器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.