import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import java.nio.charset.Charset;
import java.util.List;
@Configuration
public class RestTemplateUtil {
@Bean(name="restTemplate")
public RestTemplate init(){
CloseableHttpClient httpClient = HttpClientBuilder
.create()
.build();
RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory(httpClient));
List<HttpMessageConverter<?>>
创建RestTemplate 解决restTemplate乱码问题
最新推荐文章于 2023-09-13 15:50:29 发布
本文介绍了在使用RestTemplate进行HTTP请求时遇到的乱码问题,详细解析了问题产生的原因,并提供了解决方案,帮助读者理解和避免此类问题。
摘要由CSDN通过智能技术生成