首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Spring RestTemplate GET请求没有给出正确的响应

Spring RestTemplate GET请求没有给出正确的响应
EN

Stack Overflow用户
提问于 2019-06-19 23:05:19
回答 1查看 116关注 0票数 0

当我使用RestTemplate执行get请求时,服务器的响应与我通过curl或在浏览器中获得的响应不同

我尝试过使用URL编码,并将url登录到控制台以进一步排除故障,但无法解释这种差异。

UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(URL + "search/all")
                .queryParam("keywords", UriUtils.encode(person, StandardCharsets.UTF_8))
                .build(true);
ResponseEntity<String> responseEntity = restTemplate.getForEntity(uriComponents.toUriString(), String.class);

从RestTemplate得到的URL

https://example.com/api/v3/search/all?keywords=%C3%89tienne%20Racicot

返回结果:{}

执行:curl https://example.com/api/v3/search/all?keywords=%C3%89tienne%20Racicot

返回结果:{Person: {...} }

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56670818

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档