对象,但任何键值映射都会这样做):
HttpParams params = new BasicHttpParams() .setParameter("foo", "bar") .setParameter("thud", "grunt"); UnknownLibrary.toQueryString(params);
应该产生“foo = bar& thud = grunt”.
我知道写起来并不难,但似乎应该已经写好了.我找不到它.
List<BasicNameValuePair> params = Arrays.asList(new BasicNameValuePair("//%^ &=@#:", "//%^ &=@#:")); String query = URLEncodedUtils.format(params, "UTF-8");
翻译自:https://stackoverflow.com/questions/1405731/is-there-a-java-method-that-encodes-a-collection-of-parameters-as-a-url-query-co