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> <a href="test.jsp?pageindex=" <%=pageindex - 1%>>上一页</a> <% } if (pageindex < totalpage) { %> <a href="test.jsp?pageindex=" <%=pageindex + 1%>>下一页</a> <a href="test.jsp?pageindex=" <%=totalpage%>>尾页</a> <% } %>
------解决方案--------------------
if (currentpage == null || currentpage.isEmpty()) {
currentpage = "1";
}
------解决方案--------------------
顶
------解决方案--------------------
jsp页面报错真麻烦,不能定位到报错的地方。不过可以确认的是,肯定是Integer.parseInt(xxxxx)报错的,xxxxx的值为“”。。。
代码迷推荐解决方案:An exception occurred processing JSP page,http://www.daimami.com/search?q=33144