Java EE in Request.getparametermap () to normal map

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.