{"id":90,"date":"2023-02-14T21:46:12","date_gmt":"2023-02-14T13:46:12","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=90"},"modified":"2023-02-14T21:46:35","modified_gmt":"2023-02-14T13:46:35","slug":"url-params-map-conversion","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/14\/url-params-map-conversion\/","title":{"rendered":"url\u53c2\u6570\u548cmap\u4e4b\u95f4\u7684\u8f6c\u6362"},"content":{"rendered":"<h3>url\u53c2\u6570\u8f6c\u6362\u6210map<\/h3>\n<pre><code class=\"language-java\">\/**\n * \u5c06url\u53c2\u6570\u8f6c\u6362\u6210map\n * @param param aa=11&amp;bb=22&amp;cc=33\n * @return\n *\/\npublic static Map&lt;String, Object&gt; getUrlParams(String param) {\n    Map&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;(0);\n    if (StringUtils.isBlank(param)) {\n        return map;\n    }\n    String[] params = param.split(&quot;&amp;&quot;);\n    for (int i = 0; i &lt; params.length; i++) {\n        String[] p = params[i].split(&quot;=&quot;, 2);\n        if (p.length == 2) {\n            map.put(p[0], p[1]);\n        }\n    }\n    return map;\n}<\/code><\/pre>\n<h3>map\u8f6c\u6362\u6210url<\/h3>\n<pre><code class=\"language-java\">\/**\n * \u5c06map\u8f6c\u6362\u6210url\n * @param map\n * @return\n *\/\npublic static String getUrlParamsByMap(Map&lt;String, Object&gt; map) {\n    if (map == null) {\n        return &quot;&quot;;\n    }\n    StringBuffer sb = new StringBuffer();\n    for (Map.Entry&lt;String, Object&gt; entry : map.entrySet()) {\n        sb.append(entry.getKey() + &quot;=&quot; + entry.getValue());\n        sb.append(&quot;&amp;&quot;);\n    }\n    String s = sb.toString();\n    if (s.endsWith(&quot;&amp;&quot;)) {\n        s = StringUtils.substringBeforeLast(s, &quot;&amp;&quot;);\n    }\n    return s;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>url\u53c2\u6570\u8f6c\u6362\u6210map \/** * \u5c06url\u53c2\u6570\u8f6c\u6362\u6210map * @param param aa=11&#038;amp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-java-basic"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}