我尝试使用多个查询字符串参数调用 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);
}
问题是 '&' 字符RequestMapping value
被替换为&
如何避免这种情况?
Thanks !
所有查询参数将通过使用以下命令的分割自动从 url 中提取&
字符并映射到相应的@RequestParam
在方法声明中。
所以你不需要指定所有的键@RequestMapping
注释,您应该只指定端点值。
为了使您的示例正常工作,您只需将休息端点更改为:
@RequestMapping(method=RequestMethod.GET)
GoogleMatrixResult process(@RequestParam(value="key") String key,
@RequestParam(value="origins") String origins,
@RequestParam(value="destinations") String destin);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)