jsp 分页, 判断是第一页,和最后一页.

时间:2021-04-07 23:26:47
<%
//页的行数
int pagesize =20;
//当前页
int currentPage = 1;
try {
currentPage
= Integer.parseInt(request.getParameter("page"));
}
catch (Exception e) {
}
//总记录数
int totalRecord = 0;
//总页数
int totalPage = 0; totalRecord= 查询出所有的数据条数; totalPage=(totalRecord+pagesize-1)/pagesize; /////调用业务逻辑方法 <div align="right">
当前页<%=currentPage %>/共<%=totalPage %>
<a href="message.jsp?page=1">首页</a>
<a href="message.jsp?page=<%=currentPage==1?1:currentPage-1 %>">上一页</a>
<a href="message.jsp?page=<%=currentPage==totalPage?totalPage:currentPage+1 %>">下一页</a>
<a href="message.jsp?page=<%=totalPage %>">尾页</a></div>