想做一个歌曲的分页显示 出现java.lang.NumberFormatException: For input string: "null"
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
//按songname查找歌曲
public String getSbn(){
songlist=service.getSongByName(this.songname);
currentpage=1;
//总结果数
totalresults=songlist.size();
if(totalresults%pagesize!=0){
pagenumber=(totalresults/pagesize)+1;
}
else{pagenumber=totalresults/pagesize;
}
start=(currentpage-1)*pagesize;
end=(currentpage)*pagesize-1;
request.getSession().setAttribute("songlist",songlist);
request.getSession().setAttribute("currentpage",currentpage);
request.getSession().setAttribute("pagenumber",pagenumber);
return "searchresult";
}
//下一页
public String nextPage(){
songlist=(List<Song>) session.getAttribute("songlist");
totalresults=songlist.size();
//将object转化成int
//此处"currentpage"为空
currentpage= Integer.parseInt(String.valueOf(request.getSession().getAttribute("currentpage")));
currentpage++;
request.getSession().setAttribute("currentpage",currentpage);
if(totalresults%pagesize!=0){
pagenumber=(totalresults/pagesize)+1;
}
else{pagenumber=totalresults/pagesize;
}
start=(currentpage-1)*pagesize;
end=(currentpage)*pagesize-1;
return"addsongok";
}
jsp上调用nextpage()的部分
<% if((session.getAttribute("currentpage")!=null)&&(session.getAttribute("pagenumber")!=null)){
if(Integer.parseInt(String.valueOf(request.getSession().getAttribute("currentpage")))==Integer.parseInt(String.valueOf(request.getSession().getAttribute("pagenumber"))))
{ %><% } else { %>
<a href="SongManage_nextPage?">下一页</a>
<% }} %>
currentpage= Integer.parseInt(String.valueOf(request.getSession().getAttribute("currentpage")));这里取回的currentpage为空。请问是为什么?