对map参数进行排序
/**
* Map转换成url参数 by csl
*
* @param map
* @param isSort 是否排序
* @return
*/
public static String getURLParamSign(Map map, boolean isSort) {
StringBuffer param = new StringBuffer();
List msgList = new ArrayList();
for (Iterator it = map.keySet().iterator(); it.hasNext(); ) {
String key = (String) it.next();
String value = (String) map.get(key);
msgList.add(key + "" + value);
}
if (isSort) {
Collections.sort(msgList);
}
for (int i = 0; i < msgList.size(); i++) {
String msg = (String) msgList.get(i);
if (i > 0) {
param.append("&");
}
param.append(msg);
}
return param.toString();
}