RestTemplate 乱码
Posted albert-think
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RestTemplate 乱码相关的知识,希望对你有一定的参考价值。
public static ResponseBean getByPostData(String url,Map<String,Object> params) throws ClientProtocolException,
URISyntaxException, IOException {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/x-www-form-urlencoded");
MultiValueMap<String, Object> requestEntity = new LinkedMultiValueMap<>();
for (String key:params.keySet()) {
requestEntity.add(key,params.get(key).toString());
}
HttpEntity<MultiValueMap<String, Object>> r = new HttpEntity<>(
requestEntity, headers);
ResponseBean rspMsg = restTemplate.postForObject(url,r , ResponseBean.class);
return rspMsg;
}
以上是关于RestTemplate 乱码的主要内容,如果未能解决你的问题,请参考以下文章