动态遍历接收的参数
/** * 动态遍历获取所有收到的参数,此步非常关键,因为以后可能会加字段,动态获取可以兼容由于加字段而引起的签名异常 * * @param request * @return */ private TreeMap<String, String> getParams(HttpServletRequest request) { TreeMap<String, String> map = new TreeMap<String, String>(); Map reqMap = request.getParameterMap(); for (Object key : reqMap.keySet()) { String value = ((String[]) reqMap.get(key))[0]; System.out.println(key + ";" + value); map.put(key.toString(), value); } return map; }
如果一些非web需要改变编码
String sendData = URLEncoder.encode(trxreserve, "UTF-8");
String getData = URLDecoder.decode(sendData, "UTF-8");