/**
* Java實現PHP中的http_build_query()效果
* @param array
* key=value形式的二位數組
* @return
*/
public static String http_build_query(Map<String,Object> array){
String reString = null;
//遍歷數組形成akey=avalue&bkey=bvalue&ckey=cvalue形式的的字符串
Iterator it = array.entrySet().iterator();
while (it.hasNext()){
Map.Entry<String,Object> entry =(Map.Entry) it.next();
//中間加個過濾,去掉token和checksum
// if("token".equals(entry.getKey())||"checksum".equals(entry.getKey())){
// continue;
// }
String key = entry.getKey();
Object value = entry.getValue();
reString += key+"="+value+"&";
}
reString = reString.substring(0, reString.length()-1);
//將得到的字符串進行處理得到目標格式的字符串
reString = java.net.URLEncoder.encode(reString);
reString = reString.replace("%3D", "=").replace("%26", "&");
return reString;
}