有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么在传递数组时会发生这种情况?

我试图使用document.formname.action将值数组从.js文件中的函数传递到.jsp文件,但它创建数组索引时超出了范围

我的.js文件(注意这一行:document.detailsview.action=" "):

function savetheChanges(count)
{
    var kkot1=new Array();
    var iitemcode1=new Array();
    var dropdown11=new Array();
    var billno=document.getElementById("billno").value; 
    for(var i=0;i<count;i++)
    {   
        var selec = document.getElementById("sel"+i);
        dropdown11[i] = selec.options[selec.selectedIndex].value;
        kkot1[i]=document.getElementById("kot"+i).value;
        iitemcode1[i]=document.getElementById("itemcode"+i).value;
        //var dummydrop=dropdown1[i];
        alert(i+" "+dropdown11[i]);
        //var mydropp=dropdown11[i];        
    }
    document.detailsview.action="BillCB.jsp?method=" + "11" + "&billno="+billno+"&itemStatus1="+dropdown11+ "&kot="+kkot1+ "&itemcode="+iitemcode1;
  }

BillCB.jspmethod11):

case 11:
gotMethod = true;   
billdetails_be.billno = Integer.valueOf(request.getParameter("billno"));
String[] kotCbb=request.getParameterValues("kot");
String[] itemCbb=request.getParameterValues("itemcode");
String[] statCbb=request.getParameterValues("itemStatus1");
System.out.println("IN AVAILABLE:Size of KOT array is :" +kotCbb.length);
System.out.println("IN AVAILABLE:Size of ITEM array is:"+itemCbb.length);
System.out.println("IN AVAILABLE:size of STATUS array is:"+statCbb.length);

控制台中的输出为:

IN AVAILABLE:Size of KOT array is :19
IN AVAILABLE:Size of ITEM array is:19
IN AVAILABLE:size of STATUS array is:1

共 (0) 个答案