RestTemplate中文乱码问题
2013-11-22 19:28
274 查看
使用RestTemplate传输带有图片的表单时,需要对表单中的中文参数进行URL编码,
eg :URLDecoder.decode(name); // 使用默认的解码
params.add("name", URLEncoder.encode(name)); // 使用默认的编码
URLDecoder.decode(name,"UTF-8"); // 使用指定的解码
params.add("name", URLEncoder.encode(name,"UTF-8")); // 使用指定的编码
注意:编码和解码时,要么都指定编码 ,要么都不指定编码,一边指定编码,一边不指定编码,是错误的。
eg :URLDecoder.decode(name); // 使用默认的解码
params.add("name", URLEncoder.encode(name)); // 使用默认的编码
URLDecoder.decode(name,"UTF-8"); // 使用指定的解码
params.add("name", URLEncoder.encode(name,"UTF-8")); // 使用指定的编码
注意:编码和解码时,要么都指定编码 ,要么都不指定编码,一边指定编码,一边不指定编码,是错误的。
相关文章推荐
- 解决spring3.0.5使用RestTemplate发送post请求响应中文乱码问题
- 通过springRestTemplate发送中文乱码问题
- RestTemplate发送中文参数乱码问题
- restTemplate使用及中文乱码问题
- 关于spring中使用redis中文乱码问题(redistemplate)
- Spring RestTemplate中文乱码原因
- 解决 Thymeleaf template fragment 中文乱码问题
- Spring RestTemplate 中文乱码 简析【3.2.3Release】
- java调用arcgis soe发布的rest服务,中文传值乱码问题
- SpringBoot中,RestTemplate中文乱码解决方案
- Java HttpURLConnection模拟请求Rest接口解决中文乱码问题
- spring mvc rest风格的URL输入中文乱码问题
- ArcGIS Server REST中文乱码问题解决办法
- ArcGIS Server REST中文乱码问题解决办法
- spring3 mvc rest返回中文乱码? 解决问题
- SpringBoot restTemplate乱码问题
- RestTemplate乱码的问题 @Arthur
- RestTemplate 中文乱码
- java三大框架之spring配置template连接数据库中文乱码问题
- Spring Boot RestTemplate 中文乱码