Package Com.thunisoft.maybee.engine.utils;import Org.apache.commons.lang3.stringutils;import Java.util.HashMap; Import java.util.map;/** * map and URL parameter conversion */public class Mapurlparamsutils {/** * convert URL parameter to map * * @param p Aram aa=11&bb=22&cc=33 * @return * * public static map<string, object> geturlparams (String param) {map<string, object> Map = new hashmap<string, object> (0); if (Pubstring.isblank (param)) {return map; } string[] params = Param.split ("&"); for (int i = 0; i < params.length; i++) {string[] p = params[i].split ("="); if (p.length = = 2) {map.put (p[0], p[1]); }} return map; }/** * Convert map to URL * * @param map * @return */public static String Geturlparamsbymap (map<str ING, object> map) {if (map = = null) {return ""; } stringbuffer sb = new STRINGBUffer (); For (map.entry<string, object> entry:map.entrySet ()) {Sb.append (Entry.getkey () + "=" + Entry.getvalue ( )); Sb.append ("&"); } String s = sb.tostring (); if (S.endswith ("&")) {s = stringutils.substringbeforelast (S, "&"); } return s; }}
Map and URL query parameters are converted to each other