码迷,mamicode.com
首页 > 其他好文 > 详细

RestTemplate 乱码

时间:2018-10-25 14:02:15      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:nta   add   type   static   linked   .class   protocol   data   params   

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 乱码

标签:nta   add   type   static   linked   .class   protocol   data   params   

原文地址:https://www.cnblogs.com/albert-think/p/9848923.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!