SpringBoot项目中使用RestTemplate时出现乱码时的解决方案

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/y_bccl27/article/details/85156572

问题描述:SpringBoot项目中使用RestTemplate调用接口时,返回结果中可能会出现以下的乱码现象

解决方法:对返回的结果response.getBody()转换为utf-8格式

ResponseEntity<String> response = restTemplate.postForEntity(url,request,String.class);
String seqResult = new String(response.getBody().getBytes("ISO8859-1"),"utf-8");

猜你喜欢

转载自blog.csdn.net/y_bccl27/article/details/85156572
今日推荐