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;

}
posted @ 2018-10-25 11:46  albert_think  阅读(336)  评论(0编辑  收藏  举报