How to config spring boot application to support both UTF-8 and GBK encode?
<p>I am using spring boot in my project and I run some encoding issue.</p>

<p>In the project, there is a controller(below) which accept request with a content type header ,"application/x-www-form-urlencoded;charset=GBK".</p>

<pre><code>@RequestMapping(value = "/notify",headers ={"Content-Type=application/x-www-form-urlencoded;charset=GBK"} , method = RequestMethod.POST, produces = "application/x-www-form-urlencoded; charset=GBK")
public ResponseEntity&lt;String&gt; notify(@RequestParam(name = "p") String plain, @RequestParam("s") String signature), HttpServletRequest request){}
</code></pre>

<p>When the third party invoke this api ,they encode the request body by GBK.Once the body contain Chinese charsets,the parameter I got is wrong,which is not human readable, something like this "result������Ʒ".</p>

<p>Because the client send the request body with GBK encode,but the spring boot decode the request body with UTF-8 which is the default charset encode of spring boot.</p>

<p>The project is available different third-parties,most of them are using UTF-8,so I can not change the project encode to GBK by config the yml file with the following:</p>

<pre><code>spring:
  http:
    encoding:
      charset: GBK
        enabled: true
</code></pre>

<p>So my first thought is to reverse the wrong string I got.But I fail with the following test.</p>

<pre><code>String para = "p=result中文的&amp;s=ad98adj";
byte[] bytes = para.getBytes("GBK");

ByteChunk byteChunk = new ByteChunk();
byteChunk.setBytes(bytes , 0 , bytes.length);
byteChunk.setCharset(Charset.forName("utf-8"));
String receive = byteChunk.toString();//this is the wrong string

//reverse
byteChunk.reset();
bytes = receive.getBytes("GBK");
byteChunk.setBytes(bytes , 0 ,bytes.length);
byteChunk.setCharset(Charset.forName("GBK"));
receive = byteChunk.toString(); //still the wrong string
</code></pre>

<p><strong>So How can I use a single spring boot application to support both GBK and UTF-8 encode request.</strong></p>