public static String requestUrl(String url, Map<String, String> query) {
String keyvalue;
if (query != null) {
String[] a = new String[query.size()];
int i = 0;
for (Map.Entry<String, String> entry : query.entrySet()) {
a[i] = entry.getKey() + "=" + entry.getValue();
i++;
}
keyvalue = combine(a, "&");
} else
keyvalue = null;
return url + "?" + keyvalue;
}
在某些情况下无法获得编码的URL
public static String requestUrl(String url, Map<String, String> query) {
String keyvalue;
if (query != null) {
String[] sb = new String[query.size()];
int i = 0;
for (Map.Entry<String, String> entry : query.entrySet()) {
sb[i] = entry.getKey() + "=" + entry.getValue();
i++;
}
keyvalue = combine(a, "&");
} else
keyvalue null;
String keyvalue = createkeyvalue(query);
if (url.contains("?"))
return url + "&" + keyvalue;
return url + "?" + keyvalue;
}
它将解决您的问题