The problem of RestTemplate Accept-Charset in java

< H2 > Accept-Charset has a lot of character encoding and takes up a lot of space. < / H2 >

my code is as follows

        //set factory
        HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
        factory.setConnectTimeout(500);
        factory.setReadTimeout(3000);

        //set headers
        RestTemplate template = new RestTemplate(factory);
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
        httpHeaders.set("Accept", "*/*");
        httpHeaders.set("Accept-Charset", "utf-8");    

clipboard.png

clipboard.png,
this is the header information of the request. What I can"t understand is * * Why I overwrite Accept and Accept-Charset, but still write Accept-Charset in resttemplate, hoping someone can help me.

Mar.10,2021

whether you use the content converter StringHttpMessageConverter, if you do, you need to set
stringHttpMessageConverter.setWriteAcceptCharset (false);
for your settings to take effect

Menu