Work accumulation (ix)--pre-and post-platform transfer class map parameters

Source: Internet
Author: User

recently, when I integrated the Friend Alliance message push service at work, I encountered a The need for Ajax to pass custom parameters to the Java backend was to take Java.util.Map , but found that Ajax could not be passed java.util.Map Type of argument, which was later reluctantly taken in the way that the Vo object was adopted :

Public Extravo {private list<string> keys;  Private list<string> values; Omit Get | Set Method}

When values are taken:

if (Extravo.getkeys () = null) {for (int i = 0; i < extraVo.getKeys.size (); i++) {Broadcast.setextrafield (extravo.ge  Tkeys (). get (i), extravo.getvalues (). get (i)); }}

Although solve the problem, but really stay Meng, and then thought to find out the brain, why not List<somevo> this form? and Org.apache.commons.httpclient.NameValuePair is a class that implements Key-value (of course, this class is simple, if you don't want to introduce an extra jar The package can be implemented entirely on its own), the modified Vo object:

Public Extravo {private list<namevaluepair> customparams; Omit Get | Set Method}

When values are taken:

if (extravo.getcustomparams () = null) {for (int i = 0; i < Extravo.getcustomparams (). Size (); i++) {Broadcast.sete  Xtrafield (Extravo.getcustomparams (). get (i). GetName (), Extravo.getcustomparams (). get (i). GetValue ()); }}

This makes it easy to implement both front and rear pass the parameter of the MAP type.

Finish.

This article is from the "barrel of fake dog excrement" blog, please be sure to keep this source http://xitongjiagoushi.blog.51cto.com/9975742/1670299

Work accumulation (ix)--pre-and post-platform transfer class map parameters

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.