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