假设数据库总记录数为 totalrecordcount
每页显示记录数为:pagesize
则总页数为 pagecount=(totalrecordcount+pagesize-1)/pagesize
代码如下:
int totalrecordcount=36;
int pagesize=3;
int pagecount=(totalrecordcount+pagesize-1)/pagesize;
System.out.println("pagecount="+pagecount);