springcloud中zuul中的prefix 和 strip-prefix

  • prefix :前缀,当请求匹配前缀时会进行代理。
  • strip-prefix :代理前缀默认会从请求路径中移除,通过该设置关闭移除功能。默认是true

stripPrefix=true 时

  默认配置,转发时会自动移除前缀;

1

2

3

4

5

6

zuul:

  routes:

    api: # 路由别名,自定义即可无其他意义

      stripPrefix: true    #会将path中的前缀去除掉

      serviceId: server-api

      path: /api/**

当外部请求为 http://localhost:9000/api/getTest 时,通过网关转发路径为:http://localhost:9000/getTest?productId=20 

stripPrefix=false 时

转发时不会移除前缀;

1

2

3

4

5

6

zuul:

  routes:

    api: # 路由别名,自定义即可无其他意义

      stripPrefix: false    #会将path中的前缀不会去除掉

      serviceId: server-api

      path: /api/**

当外部请求为 http://localhost:9000/api/getTest 时,通过网关转发路径为:http://localhost:9000/getTest?productId=20  

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值