如何配置Spring Gateway路由至@RequestMapping("**/file")的控制器
Spring Cloud Gateway 匹配含/file任意路径的配置
你只需要把路径断言(Predicate)改成Path=/**/file/**即可,完整配置如下:
spring.cloud.gateway.routes[0].id=file spring.cloud.gateway.routes[0].uri=http://localhost:8080 spring.cloud.gateway.routes[0].predicates[0]=Path=/**/file/**
规则说明
/**表示匹配任意数量的路径段(包括零个),所以/**/file/**会匹配所有包含/file的URL:- 比如
/file、/a/file、/a/b/c/file、/a/file/d/e这类请求都会被匹配到。
- 比如
- 这个规则和你控制器上的
@RequestMapping("**/file")完全兼容,网关转发后的请求能被控制器正常接收处理。
内容的提问来源于stack exchange,提问作者antonundrul
相关产品推荐
相关产品推荐

