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

34. RestTemplate中文乱码

时间:2017-08-24 20:14:19      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:resttemplate

解决方法:

设置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中文乱码

标签:resttemplate

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

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