本文介绍了如何将地图转换为 url 查询字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您知道任何可以将 Map 转换为 URL 友好的查询字符串的实用程序类/库吗?
Do you know of any utility class/library, that can convert Map into URL-friendly query string?
示例:
我有一张地图:
"param1"=12, "param2"="cat"我想得到:
param1=12¶m2=cat最终输出
relativeUrl+param1=12¶m2=cat 推荐答案我看到的最强大的现成方案是 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.
更多推荐
如何将地图转换为 url 查询字符串?
发布评论