Although the parameter map can be easily obtained by Request.getparametermap () in a Java Web project, the resulting map is not the same as the normal map, it is locked, and cannot be put, get, and so on as the normal map. This method will get the parameter map back as an operational normal map
1 /**2 * Get the parameter map from request and return a readable map3 * 4 * @paramRequest5 * @return6 */7@SuppressWarnings ("Unchecked")8 Public StaticMap Getparametermap (httpservletrequest request) {9 //parameter MapTenMap Properties =Request.getparametermap (); One //return value Map AMap Returnmap =NewHashMap (); -Iterator entries =Properties.entryset (). iterator (); - map.entry Entry; theString name = ""; -String value = ""; - while(Entries.hasnext ()) { -Entry =(Map.entry) Entries.next (); +Name =(String) Entry.getkey (); -Object valueobj =Entry.getvalue (); + if(NULL==valueobj) { AValue = ""; at}Else if(Valueobjinstanceofstring[]) { -String[] values =(string[]) valueobj; - for(inti=0;i<values.length;i++){ -Value = Values[i] + ","; - } -Value = value.substring (0, Value.length ()-1); in}Else{ -Value =valueobj.tostring (); to } + returnmap.put (name, value); - } the returnReturnmap; *}
Java EE in Request.getparametermap () to normal map