private String sendMessage(String opendId, String msgtype, Map<String, String> contentMap) throws UnsupportedEncodingException {
Map<String, Object> replyMessageMap = new HashMap<String, Object>();
replyMessageMap.put("touser", opendId);
replyMessageMap.put("msgtype", msgtype);
replyMessageMap.put(msgtype, contentMap);
String messageJson = JSONObject.toJSONString(replyMessageMap);
messageJson = new String(messageJson.getBytes(), "UTF-8");
System.out.println(WechatAppletInterfaceUtils.getAccessToken());
System.out.println(messageJson);
String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + WechatAppletInterfaceUtils.getAccessToken();
System.out.println("url"+url);
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.postForEntity(url, messageJson, String.class).getBody();
System.out.println(result);
// 发送结果
return result;
}
请问怎么解决
RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters() .set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));