JSP项目开发实战入门第一章 新闻列表 “数据服务器出现错误” 问题的解决方法(2)
发表在JSP答疑区
2020-12-21
是否精华
是
否
版块置顶:
是
否
Function.java 中这个StrToInt有问题, 因为parseInt(String s)对与空字符串“”等会抛出异常 NumberFormatException.
所以我做了一下修改,解决了这个异常。
//modified code - added safeguard of empty string
public int StrToInt(String s) {
String filteredStr = CheckReplace(s);
int retInt = 0;
if (( filteredStr == ""))
retInt= 0;
else {
try {
retInt = Integer.parseInt(filteredStr);
} catch (Exception e) {
e.printStackTrace();
}
}
return retInt;
}于2020-12-21 20:32:14编辑

购物车
发表新帖
立即签到







