为类似于 google 映射的属性请求具有特殊字符的映射
request mapping with special char for attributes similar to google maps
我正在使用 Spring 引导,我想以类似于 Google 映射的方式传递两个双精度值:
而不是 /api?x=1.1&y=2.2 并获取我想要执行的请求参数:/api/@1.1 ,2.2
在控制器级别,如何从第二个 get 请求中获取这两个参数?
@GetMapping("/api/@{term:.+}")
public void index(@PathVariable String term) {
// term is whatever after the "@"
// you can parse the term to what you want
// {term:.+} is a regex mapping for including the last dot
}
例如
如果你请求 ../api/@1.1,2.2
术语将为“1.1,2.2”。
用“,”拆分术语并将字符串转换为双精度数。
我正在使用 Spring 引导,我想以类似于 Google 映射的方式传递两个双精度值: 而不是 /api?x=1.1&y=2.2 并获取我想要执行的请求参数:/api/@1.1 ,2.2
在控制器级别,如何从第二个 get 请求中获取这两个参数?
@GetMapping("/api/@{term:.+}")
public void index(@PathVariable String term) {
// term is whatever after the "@"
// you can parse the term to what you want
// {term:.+} is a regex mapping for including the last dot
}
例如
如果你请求 ../api/@1.1,2.2
术语将为“1.1,2.2”。
用“,”拆分术语并将字符串转换为双精度数。