How to convert map to url query string?

前端 未结 17 1587
盖世英雄少女心
盖世英雄少女心 2020-11-27 13:39

Do you know of any utility class/library, that can convert Map into URL-friendly query string?

Example:

I have a map:

\"param1\"=12,
\"param2         


        
17条回答
  •  天命终不由人
    2020-11-27 14:23

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

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

    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.

提交回复
热议问题