首页 > 其他 > 详细

34. RestTemplate中文乱码

时间:2017-08-24 19:39:22      阅读:286      评论:0      收藏:0      [点我收藏+]

解决方法:

设置httpheader的时候,加上utf-8编码

String body = "中文你好";
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");  
headers.setContentType(type);  
					
HttpEntity<String> formEntity = new HttpEntity<String>(body, headers);


本文出自 “www.bogo.com” 博客,请务必保留此出处http://483181.blog.51cto.com/473181/1959017

34. RestTemplate中文乱码

原文:http://483181.blog.51cto.com/473181/1959017

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!