resttemplate 中文乱码问题处理

添加header,增加charset=gbk

MultiValueMap<String, String> postParameters = new LinkedMultiValueMap<>();
postParameters.add("params", send.toJSONString());
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/x-www-form-urlencoded;charset=gbk");
HttpEntity<MultiValueMap<String, String>> r = new HttpEntity<>(postParameters, headers);
ResponseEntity<JSONObject> result = restTemplate.postForEntity(url, r, JSONObject.class);

你可能感兴趣的:(java)