当前位置: 代码迷 >> Web前端 >> java.lang.NumberFormatException: For input string: ""
  详细解决方案

java.lang.NumberFormatException: For input string: ""

热度:1218   发布时间:2012-08-13 13:21:53.0
java.lang.NumberFormatException: For input string: ""
问题描述:
    前台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循环里添加判断语句就通过了
  相关解决方案