When we transfer parameters, we often encounter parameters with the same attributes being transferred to the background. The best choice is to use an array. When we send it to the background, we only need to define and use the array normally in javascript and pass it to the background as a parameter:
var arry= new Array();
arry[0] = "102";
arry[1] = "103" ;
arry[2] = "104";
url = "test.jsp?arry=" arry;
Accepting method in the background:
[code]
String arry = request.getParmeter("arry");
String[] par = arry.split(",");
[code]
this At this time, par becomes an array in java. The value of arry is "102,103,104", which means that during the transmission process, the browser automatically converts the JavaScript array parameters into comma-separated strings. We only need to take out the string in the background and split it according to commas. It can be the corresponding array.
In addition, I have seen people using json on the Internet, but I don’t feel comfortable with it. The request.getParmeterValues method is also useful. The specific usage is as follows:
Use the same parameter in the foreground and assign and pass it multiple times:
url="test.jsp?arry=102&arry=103&arry=104 "
Take out in the background:
String arry[] = request.getParmeterValues("arry");
The value of arry at this time is {102,103,104}
Choose the specific method according to your own habits!