jer*_*eca 5 spring spring-boot feign
我尝试使用多个查询字符串参数调用Google API.奇怪的是,我找不到办法做到这一点.
这是我的FeignClient:
@FeignClient(name="googleMatrix", url="https://maps.googleapis.com/maps/api/distancematrix/json")
public interface GoogleMatrixClient {
@RequestMapping(method=RequestMethod.GET, value="?key={key}&origins={origins}&destinations={destinations}")
GoogleMatrixResult process(@PathVariable(value="key") String key,
@PathVariable(value="origins") String origins,
@PathVariable(value="destinations") String destinations);
}
Run Code Online (Sandbox Code Playgroud)
问题是'&'的特征RequestMapping value被替换为&
怎么避免这个?
谢谢 !
Ale*_*can 10
所有查询参数将通过使用该&字符的拆分自动从URL中提取,并映射到方法声明中的相应@RequestParam.因此,您不需要指定@RequestMapping注释的所有键,只应指定端点值.
为了您的示例,您只需将rest-endpoint更改为
@RequestMapping(method=RequestMethod.GET)
GoogleMatrixResult process(@RequestParam(value="key") String key,
@RequestParam(value="origins") String origins,
@RequestParam(value="destinations") String destinations);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8525 次 |
| 最近记录: |