首页 > 解决方案 > 蚂蚁匹配器以

问题描述

我的 spring 安全配置需要一个 ant matcher。此匹配器应匹配以下网址

现在我有这个 .antMatchers("/health").permitAll(),但这拒绝/contolller/health

然后我尝试.antMatchers("/*/health").permitAll()了,但这拒绝了/health

那么有什么建议吗?

PS 我想使用 antMatchers 方法,而不是 regexMatchers

标签: javaspringspring-security

解决方案


.antMatchers("/health")仅指特定的蚂蚁。

您可以添加“/**”.antMatchers("/controller/**")来引用其所有子文件夹

您可以在 /health 之前添加“**/”.antMatchers("/**/health")以匹配位于任何位置的“health”目录或.antMatchers("/**/health/**")匹配位于任何位置的“health”目录中的所有文件

或者.antMatchers("/health", "/contoller/health")用逗号写所有特定的子文件夹。


推荐阅读