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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM