[英]Spring Security antMatcher expression not works with path variable
I need to provide certain role for accessing a URL in the following format: 我需要提供某些角色来访问以下格式的URL:
/connector/{programId}/order/{anything here}
Where programId
is an integer value so I'd tried the following and it doesn't work at all. 其中
programId
是整数值,因此我尝试了以下操作,但它根本不起作用。
.antMatchers('/connector/{programId:\\d+}/order/**').access("hasRole('CONNECTOR')")
But when I used **
instead of the programId
part it's working well. 但是,当我使用
**
代替programId
部分时,它运行良好。 But how can I make it work with pathVariable (which is always an integer). 但是,如何使它与pathVariable(始终为整数)一起使用。
您应该使用RegexRequestMatcher
而不是AntPathRequestMatcher
。
.regexMatchers("/connector/(\\d+)/order/.*").access("hasRole('CONNECTOR')")
我正在使用: .regexMatchers("/connector/(\\\\d+)/order/.*").access("hasRole('CONNECTOR')")
但是服务器响应405错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.