首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

java.lang.NumberFormatException: For input string: ""解决思路

2013-09-11 
java.lang.NumberFormatException: For input string: org.apache.jasper.JasperException: An exceptio

java.lang.NumberFormatException: For input string: ""
org.apache.jasper.JasperException: An exception occurred processing JSP page /test.jsp at line 48

45: if (currentpage == null) {
46: currentpage = "1";
47: }
48: int pageindex = Integer.parseInt(currentpage);
49: if (pageindex < 1) {
50: pageindex = 1;
51: } else if (pageindex > totalpage) {




Java code
request.setCharacterEncoding("GBK");            page p = new page();            int count = p.getCount();            int pagesize = 2;            int totalpage = p.getTotalpage(count, pagesize);            String currentpage = request.getParameter("pageindex");            //System.out.println(currentpage);            if (currentpage == null) {                currentpage = "1";            }            int pageindex = Integer.parseInt(currentpage);            if (pageindex < 1) {                pageindex = 1;            } else if (pageindex > totalpage) {                pageindex = totalpage;            }            List<News> list = p.getnewslist(pageindex, pagesize);            //request.setAttribute("newslist", list);            for (News news : list) {        %>        <%=news.getTitle()%><br />        <%            }        %>        当前页数[<%=pageindex%>/<%=totalpage%>]        <%            if (pageindex > 1) {        %>        <a href="test.jsp?pageindex=1">首页</a>&nbsp;        <a href="test.jsp?pageindex=" <%=pageindex - 1%>>上一页</a>&nbsp;        <%            }            if (pageindex < totalpage) {        %>        <a href="test.jsp?pageindex=" <%=pageindex + 1%>>下一页</a>&nbsp;        <a href="test.jsp?pageindex=" <%=totalpage%>>尾页</a>&nbsp;        <%            }        %>


[解决办法]
if (currentpage == null || currentpage.isEmpty()) {
currentpage = "1";
}
[解决办法]

探讨
if (currentpage == null || currentpage.isEmpty()) {
currentpage = "1";
}

[解决办法]
jsp页面报错真麻烦,不能定位到报错的地方。不过可以确认的是,肯定是Integer.parseInt(xxxxx)报错的,xxxxx的值为“”。。。
我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html

热点排行