问题描述:
前台jsp页面向后台传数组(实际上把数组元素的值拼接成字符串),js代码如下:
var myForm = document.getElementById("myform"); myForm.action = "${path}/master/employeeTransfer/employeeTransfer!updateEmpGroupMove.action?empId=" + empId + "&allGroupId=" + data; myForm.submit();
后台接收代码:
String allGroupId = this.getStringParam("allGroupId").trim(); Long groupId = 0L; String[] groupIdArray = allGroupId.split("\\|"); for(int i = 0;i<groupIdArray.length;i++){ groupId = Long.parseLong(groupIdArray[i].trim()); }
debug时报错:
java.lang.NumberFormatException: For input string: ""
仔细看variables的值发现有“”的存在,于是在for循环里添加判断语句就通过了