0

I am trying to post an array of JavaScript into an array of Strings in Java. It goes like this...

My JavaScript code:

var quantity_arr = new Array();

for (var i=0; i< <%= cart.size() %>; i++) {
    quantity_arr[i] = document.getElementsByClassName("quantity")[i].value;
}
xmlhttp.send("sum_of_order="+sum_of_order+"&credits_number="+credits_no+"&credit_card_number="+credit_card_number+"&quantity_arr="+quantity_arr);

This is my Java code:

String[]  myParams =new String[cart.size()];
String order_id=Integer.toString(temp);
String customer_id="'"+session.getAttribute("user_id")+"'";
String date= "15/29/12";
String sum=request.getParameter("sum_of_order");
String credit_card= "'"+request.getParameter("credit_card_number")+"'";
String credits="'"+request.getParameter("credits_number")+"'";
myParams = request.getParameterValues("quantity_arr");

All the params works fine except the myParams array that gets nothing. Can someone help me with this?

4

2 回答 2

0

请看: http: //support.dataweb.com/Help/default.view ?Topic=Request.getParameterValues ()

基本上,你不能直接通过,"quantity_arr="+quantity_arr但你必须使用:

"quantity_arr="+quantity_arr[0]+"&quantity_arr="+quantity_arr[1]+"&quantity_arr="+quantity_arr[2]+ ...
于 2012-11-11T20:21:42.130 回答
0

尝试

String[]  myParams = request.getParameterValues("quantity_arr").split(",");
于 2012-11-11T20:13:52.340 回答