/** * <p>Desc:weChat构建请求参数</p> * <p>参数名ASCII码从小到大排序(字典序)</p> * @param params * @return */ public static String buildBodyXml(Map<String,Object> params){ SortedMap<String,Object> sort=new TreeMap<String,Object>(params); Set<String> keySet = sort.keySet(); StringBuilder sb = new StringBuilder("<xml>"); for (Object key : keySet) { sb.append(String.format("<%s>%s</%s>", key, params.get(key), key)); } sb.append("</xml>"); return sb.toString(); }
全文完,感谢您的耐心阅读~
欢迎大家关注我的公众号