When we transmit parameters, we often encounter parameters that send some of the same attributes to the background, and the best option is to use arrays. When we transfer to the background, we simply define and use the array in JavaScript and pass it as a parameter to the background:
Copy Code code as follows:
var arry= new Array ();
ARRY[0] = "102";
ARRY[1] = "103";
ARRY[2] = "104";
url = "test.jsp?arry=" +arry;
In the background to accept the method:
[Code]
String Arry = Request.getparmeter ("Arry");
string[] par = arry.split (",");
[Code]
The par then becomes an array in Java. Where the value of Arry is "102,103,104" that is, in the course of the transfer, the browser automatically converts the JavaScript array parameters into comma-delimited strings, and we only need to remove the string in the background and divide it into the corresponding array by commas.
In addition, I've seen the use of JSON on the internet, it doesn't feel good. Also useful request.getparmetervalues method, the specific use is as follows:
Use the same parameter in the foreground and assign the value more than once:
Url= "test.jsp?arry=102&arry=103&arry=104"
Out in the background:
String arry[] = request.getparmetervalues ("Arry");
The value of the Arry at this time is {102,103,104}
The concrete way according to own custom choice!