GET ResponseEntity<XimoApiResult<TokenResult>> responseEntity = restTemplate.exchange(url, HttpMethod.GET, null, reference, baseRequest.getAppId(), baseRequest.getAppSecret());
执行进入execute方法后,
public <T> T execute(String url, HttpMethod method, @Nullable RequestCallback requestCallback, @Nullable ResponseExtractor<T> responseExtractor, Object... uriVariables) throws RestClientException {
URI expanded = this.getUriTemplateHandler().expand(url, uriVariables);
return this.doExecute(expanded, method, requestCallback, responseExtractor);
}
执行完URI expanded = this.getUriTemplateHandler().expand(url, uriVariables); url参数没有被替换
如:https://xxxx.com/app/extapi/getAccessToken?appId={}
此时 需要注意 应该将url改为:
https://xxxx.com/app/extapi/getAccessToken?appId={appId}
本文探讨了在使用RESTful API时遇到的问题,即在调用GET方法时,URL中的参数未被正确替换。通过分析`restTemplate.exchange()`方法的执行流程,指出在`URIexpanded=this.getUriTemplateHandler().expand(url,uriVariables);`这一步,URL中的`{appId}
9806

被折叠的 条评论
为什么被折叠?



