您当前的位置: 首页 >  spring

qq_34412985

暂无认证

  • 0浏览

    0关注

    1061博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

springcloud中zuul中的prefix 和 strip-prefix

qq_34412985 发布时间:2020-07-24 00:33:40 ,浏览量:0

  • 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  

关注
打赏
1653291990
查看更多评论
立即登录/注册

微信扫码登录

0.4003s