Jir*_*Liu 2 spring spring-cloud spring-cloud-gateway
来自 Spring.io 给出的有关 Spring Cloud 的文档:

路径路由谓词工厂采用两个参数:Spring PathMatcher 模式列表和名为 matchOptionalTrailingSeparator 的可选标志。
它提到了一个可选标志,matchOptionalTrailingSeparator但没有更多描述。
这个标志有什么用以及如何使用这个标志?谢谢
该参数matchOptionalTrailingSeparator用于确定给定的 Path 谓词是否也应该与带有尾部斜杠的请求匹配/。默认情况下,该值为true。
例如下面的路线
spring:
cloud:
gateway:
routes:
- id: host_route
uri: https://example.org
predicates:
- Path=/foo/{segment}
Run Code Online (Sandbox Code Playgroud)
将匹配请求/foo/{segment}和/foo/{segment}/
但如果写成:
spring:
cloud:
gateway:
routes:
- id: host_route
uri: https://example.org
predicates:
- Path=/foo/{segment},false
Run Code Online (Sandbox Code Playgroud)
它不会匹配带有尾部斜杠的请求/,即它只会匹配/foo/{segment}和不匹配/foo/{segment}/
| 归档时间: |
|
| 查看次数: |
1506 次 |
| 最近记录: |