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

<%
      //页的行数
   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>

 

posted @ 2016-11-18 13:46  张好好  阅读(3713)  评论(0编辑  收藏  举报