Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot Spring Cloud Gateway不';看不到url请求末尾的斜杠_Spring Boot_Spring Cloud Gateway - Fatal编程技术网

Spring boot Spring Cloud Gateway不';看不到url请求末尾的斜杠

Spring boot Spring Cloud Gateway不';看不到url请求末尾的斜杠,spring-boot,spring-cloud-gateway,Spring Boot,Spring Cloud Gateway,我有以下配置: gateway: discovery: locator: enabled: true predicates: - name: Path args: pattern: "'/api/'+serviceId.toLowerCase()+'/**'" filters: - name: RewritePath args: regexp: &q

我有以下配置:

gateway:
  discovery:
  locator:
    enabled: true
    predicates:
      - name: Path
        args:
          pattern: "'/api/'+serviceId.toLowerCase()+'/**'"
    filters:
      - name: RewritePath
        args:
          regexp: "'/api/' + serviceId.toLowerCase() + '/(?<remaining>.*)'"
          replacement: "'/${remaining}'"
网关:
发现:
定位器:
已启用:true
谓词:
-名称:路径
args:
模式:“'/api/'+serviceId.toLowerCase()+'/**”
过滤器:
-名称:重写路径
args:
regexp:“'/api/'+serviceId.toLowerCase()+'/(?*)”
替换:“'/${剩余的}”
如果我使用
…api/serviceName/
发送请求-确定

但是如果我发送一个带有
…api/serviceName
的请求,它将返回404notfound

如何更改属性,以便在不使用斜杠的情况下使用URL


谢谢

我相信您在谓词正则表达式中强制使用斜杠:

pattern: "'/api/'+serviceId.toLowerCase()+'/**'"
尝试将其设置为有条件的(0或1个“/**”实例):


问题是过滤器中有多余的斜杠:

这:

regexp:“'/api/'+serviceId.toLowerCase()+'/(?*)”
替换:“'/${剩余的}”
应替换为以下内容:

regexp: "'/api/' + serviceId.toLowerCase() + '(?<remaining>.*)'"
                replacement: "'/${remaining}'"
regexp:“'/api/'+serviceId.toLowerCase()+'(?*)”
替换:“'/${剩余的}”
regexp: "'/api/' + serviceId.toLowerCase() + '/(?<remaining>.*)'"
                replacement: "'/${remaining}'"
regexp: "'/api/' + serviceId.toLowerCase() + '(?<remaining>.*)'"
                replacement: "'/${remaining}'"