一種新的程式設計思路(下):附 自動分頁2-1 ntPage.jsp (轉)

worldblog發表於2007-12-12
一種新的程式設計思路(下):附 自動分頁2-1 ntPage.jsp (轉)[@more@]

ntPage.

-------------------------------------------------------------------

  int PAGESIZE = 10;
  int old_PAGESIZE = PAGESIZE ;
 int curPage = 1;
 int pageCount=0;
 int iStart=0;
 int iCount=0;
  int totalRecordCount = ntP.rowCount ;
 boolean onlyOnePage = true ;
 
 try {
  if( request.getParameter("pagesize")!=null )
  PAGESIZE = Integer.parseInt(request.getParameter("pagesize"));
  if( request.getParameter("pagesize_post")!=null )
  PAGESIZE = Integer.parseInt(request.getParameter("pagesize_post")); 
 }catch(Exception ePage13){
 PAGESIZE = old_PAGESIZE ;
 }
 
 if( PAGESIZE < totalRecordCount )
  onlyOnePage = false ;
 try {
  curPage = Integer.parseInt(request.getParameter("page"));
 }catch(Exception e){
 curPage = 1;
 }
 if ( totalRecordCount > 0)
 {
 pageCount = totalRecordCount / PAGESIZE;
 if ( totalRecordCount % PAGESIZE != 0)
  pageCount += 1;
 if (curPage < 1)
  curPage = 1;
 if (curPage > pageCount)
  curPage = pageCount;
 
 iStart = (curPage-1) * PAGESIZE;
 iCount = totalRecordCount - iStart;
 if (iCount > PAGESIZE)
  iCount = PAGESIZE;
 iCount = iStart + iCount ; 
 }
%>


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-991644/,如需轉載,請註明出處,否則將追究法律責任。

相關文章