How to convert map to url query string?

前端 未结 17 1537
盖世英雄少女心
盖世英雄少女心 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:13

    Using EntrySet and Streams:

    map
      .entrySet()
      .stream()
      .map(e -> e.getKey() + "=" + e.getValue())
      .collect(Collectors.joining("&"));
    

提交回复
热议问题