public static Map<String,Object> getQueryParams(String url) {
try {
Map<String, Object> params = new HashMap<String, Object>();
for (String param : url.split("&")) {
String[] pair = param.split("=");
String key = URLDecoder.decode(pair[0], "UTF-8");
String value = "";
if (pair.length > 1) {
value = URLDecoder.decode(pair[1], "UTF-8");
}
params.put(key, value);
}
return params;
} catch (UnsupportedEncodingException ex) {
throw new AssertionError(ex);
}
}
把Url解析成map对象
最新推荐文章于 2023-11-23 18:37:30 发布