且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将地图转换为 url 查询字符串?

更新时间:2023-02-23 09:33:24

我看到的最强大的现成方案是 URLEncodedUtils 类来自 Apache Http 组件(HttpClient 4.0).

The most robust one I saw off-the-shelf is the URLEncodedUtils class from Apache Http Compoments (HttpClient 4.0).

URLEncodedUtils.format() 方法正是您所需要的.

The method URLEncodedUtils.format() is what you need.

它不使用 map,所以你可以有重复的参数名称,比如,

It doesn't use map so you can have duplicate parameter names, like,

  a=1&a=2&b=3

并不是我推荐这种使用参数名称.

Not that I recommend this kind of use of parameter names.