内容简介:翻译自:https://stackoverflow.com/questions/1405731/is-there-a-java-method-that-encodes-a-collection-of-parameters-as-a-url-query-co
有没有广泛使用的 Java 库可以像 dojo.objectToQuery()
那样做什么?例如. (假设使用HttpCore的 HttpParams
对象,但任何键值映射都会这样做):
HttpParams params = new BasicHttpParams()
.setParameter("foo", "bar")
.setParameter("thud", "grunt");
UnknownLibrary.toQueryString(params);
应该产生“foo = bar& thud = grunt”.
我知道写起来并不难,但似乎应该已经写好了.我找不到它.
为什么重新发明轮子? Apache HttpClient
有URLEncodedUtils:
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
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- Scala 中的集合(二):集合性能比较
- Scala 中的集合(二):集合性能比较
- 《面试知识,工作可待:集合篇》:Java 集合面试知识大全
- 如何对集合对象求合计,然后追加在该集合对象中
- MongoDB指南---14、特殊的索引和集合:固定集合、TTL索引、全文本索引
- Python 集合相关操作
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Beginning Google Maps API 3
Gabriel Svennerberg / Apress / 2010-07-27 / $39.99
This book is about the next generation of the Google Maps API. It will provide the reader with the skills and knowledge necessary to incorporate Google Maps v3 on web pages in both desktop and mobile ......一起来看看 《Beginning Google Maps API 3》 这本书的介绍吧!