Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/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 UriTemplate解析器解释通配符_Spring_Spring Mvc - Fatal编程技术网

Spring UriTemplate解析器解释通配符

Spring UriTemplate解析器解释通配符,spring,spring-mvc,Spring,Spring Mvc,我有过这样的经历 /{repository}/{id}/action/{methodName}/** org.springframework.data.rest.webmvc.util.UriUtils使用org.springframework.web.util.UriTemplate在findMappingVariable方法中获取变量 将UriTemplate.Parser生成模式设置为此值 \Q/\E(.*)\Q/\E(.*)\Q/action/\E(.*)\Q/**\E 为什么不这样

我有过这样的经历

/{repository}/{id}/action/{methodName}/**
org.springframework.data.rest.webmvc.util.UriUtils使用org.springframework.web.util.UriTemplate在findMappingVariable方法中获取变量

将UriTemplate.Parser生成模式设置为此值

\Q/\E(.*)\Q/\E(.*)\Q/action/\E(.*)\Q/**\E
为什么不这样做呢

\\Q/\\E(.*)\\Q/\\E(.*)\\Q/action/\\E(.*)\\Q/\\E(.*)\\Q\\E
由于这个特性,我在那里有一张空地图

Map<String, String> variables = new org.springframework.web.util.UriTemplate(mapping).match(lookupPath);

我认为URI模板中不允许使用
**
段。在这种情况下,如果多个段由
**
部分匹配,那么在获取路径变量时您会期望什么


请注意,如果您试图构建模板以进行REST调用,则应检查RestTemplate和UriComponentsBuilder()。

如果您希望有一个与常规表达式匹配的
UriTEmplate
,例如,您可以使用它

/test service/test endpoint/countries/1/cities/2

/test service/test endpoint/people/5/成人/6

可以分别与
UriTemplate
匹配

/test service/test endpoint/countries/{id}/cities/{id}

/test-service/test-endpoint/people/{id}/maindants/{id}

如果要同时匹配两个

/test service/test endpoint/{:.*}

这里是链接

 /educationDistrict/308/action/resetAddressesForYear/1