日期:2014-05-16  浏览次数:20511 次

等待中 急求高手指点 jsp分页操作 为什么老是提示空指针
正在做的东西,两个页面的代码和方法是一样的,这个偏显示有错,很是纠结,不知道究竟哪错了,求哪位高手指点下,不胜感激


换页程序代码,我在另一个网页里面是一模一样的,显示是正常的,但是在这个网页里点击下一页偏提示是空指针,
jsp里:
<form name="formpage" action="./servlet/ReinfServlet" align="center" method="post">
<table>
  
<input type="hidden" name="opflag" value="changePage"/>
<input type="hidden" name="currentPage" value="<%=pagehelp.getCurrentpage() %>"/>  
<input type="hidden" name="condi" value="<%=pagehelp.getCondition()%>"/>
<tr>
<td height=25 width="105"></td><td height=25 cols="3" align="center"><%=pagehelp.getPagebar()%></td>
</tr>
</table>
</form>

servlet里:
if("changePage".equals(opflag)){
String sqlCondition =" ";
sqlCondition=request.getParameter("condi");
String currentpage=request.getParameter("currentPage");
//System.out.println(currentpage);
int intcurrentpage=Integer.parseInt(currentpage);
StuInfDAO stuinfdao =null;
PageHelp pagehelp=new PageHelp();
//System.out.println(intcurrentpage+sqlCondition+intcurrentpage);//点击下一页,显示“2 2”是正常的,说明已经传回来要显示第二页了 
try {
pagehelp=stuinfdao.queryInfo(sqlCondition,intcurrentpage);//提示空指针的一行
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("pagehelp",pagehelp);
//response.sendRedirect("../Contact/AllContact.jsp");
request.getRequestDispatcher("../Stuinf/AllStu.jsp").forward(request,response);

}



queryInfo程序代码:在第一页时显示正常,那这个程序应该是没问题的
public PageHelp queryInfo(String condi,int currentPage) throws SQLException {
conn=dbc.getConnection();
Statement sm=conn.createStatement();


int recordcount=0;
ResultSet rs=null;
String sql="select count(*) recordcount from StuInf where 1=1 "+condi;
rs=sm.executeQuery(sql);
//System.out.println(rs.getInt("recordcount"));
if(rs.next()){
recordcount=rs.getInt("recordcount");
}
int startNum=(currentPage - 1) * PageHelp.pagesize+1;//由于数据库中没有第0条记录所以要进行+1修正
int endNum= currentPage* PageHelp.pagesize+1;//查询结束行号
int N=recordcount-startNum+1;
//System.out.println(startNum);
//System.out.println(N);
String pagesql="select top 3* from (select top "+N+"* from (select * from StuInf where 1=1 "+condi+")t2 order by StuID desc)t3 order by StuID asc"; 
rs=sm.executeQuery(pagesql);
List info=new ArrayList();
StuInfVO stuinfvo =null;
while(rs.next()){
stuinfvo=new StuInfVO();
stuinfvo.setStuID(rs.getString("StuID"));
stuinfvo.setStuName(rs.getString("StuName"));
//Date dstime=
//java.sql.Date stime=rs.getDate("stime");

stuinfvo.setStuSex(rs.getInt("StuSex"));
//oaplanvo.setEtime(rs.getTimestamp("stime"));
stuinfvo.setStuGrade(rs.getInt("StuGrade"));
stuinfvo.setBirthPlace(rs.getString("BirthPlace"));
stuinfvo.setmajor(rs.getString("major"));
stuinfvo.setZZMM(rs.getString("ZZMM"));
stuinfvo.setTel(rs.getString("Tel"));
stuinfvo.setEthnic(rs.getString("Ethnic"));
stuinfvo.setDorm(rs.getString("Dorm"));
stuinfvo.setQQ(rs.getInt("QQ"));
stuinfvo.setEmail(rs.getString("Email"));
stuinfvo.setDegree(rs.getString("Degree"));


info.add(stuinfvo);
}
PageHelp pagehelp= new PageHelp(currentPage,recordcount,condi,