0

我收到以下异常org.zkoss.zk.ui.UiExceptionjava.lang.NumberFormatException. 有人可以帮忙吗?我的堆栈跟踪如下:

Nov 08, 2013 10:43:17 AM org.zkoss.zk.ui.impl.UiEngineImpl handleError:1359
SEVERE: >>org.zkoss.zk.ui.UiException: For input string: "Enter Number"
>>java.lang.NumberFormatException: For input string: "Enter Number"
>>  at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
>>  at java.lang.Double.parseDouble(Unknown Source)
>>  at com.abcd.acd.a.web.viewmodel.FolderInfoEditViewModel.loadFolderInfoList(FolderInfoEditViewModel.java:633)
>>  at com.abcd.acd.a.web.viewmodel.FolderInfoEditViewModel.afterCompose(FolderInfoEditViewModel.java:116)
>>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


我的祖尔文件:

<zk if="${civilInfoData.infoType.equalsIgnoreCase('n') and !civilInfoData.encrypted }">
       <doublebox value="@bind(civilInfoData.folderInforecord.infoValueNumeric)" 
           hflex="1" placeholder="@load(vm.getText('FolderInfoDetail:LABEL_VALUE'))"
           mandatory="@load(civilInfoData.folderInforecord.valueRequired)"
           maxlength="10" 
           tooltiptext="@load(vm.getText('FolderInfoDetail:ENTER_NUMBER'))">
        </doublebox>
</zk>


视图模型(FolderInfoEditViewModel.java):

 if (info.getInfoType().equalsIgnoreCase("n")) {
       if (StringUtils.isNotBlank(info.getFolderInforecord().getInfoValue()) &&
           !info.getFolderInforecord().getInfoValue().equalsIgnoreCase("null")) {

                     info.setInfoNumericValue(Double.parseDouble(
                                                 info.getFolderInforecord()
                                                     .getInfoValue()));

        }
  }

有人能告诉我如何解决这个问题吗?

谢谢

4

1 回答 1

2

info.getFolderInforecord().getInfoValue()正在返回String未成功解析为 a 的 a double,这就是您得到 a 的原因NumberFormatException。没有更多信息,我只能这么说。

您只是在检查它是否为空白且不等于“null”。您可以通过将代码包装try/catch在您处理NumberFormatException

于 2013-11-08T05:28:20.367 回答