一個用JSP實現的分頁的類及調用方法

來源:互聯網
上載者:User

//PageCt.java 分頁的類
/*
*** @version ***********
*** Created on 2001年6月25日, 下午14:41
**************************************
*/
package vod;
import java.sql.*;
import java.util.*;

public class PageCt
{
private long l_start; //開始紀錄
private long l_end; //結束紀錄
private long l_curpage; //當前頁數
private long l_totalnum;//總記錄數
private int int_num=5; //每頁10條
private long l_totalpage; //總的頁數

public void Init(long currentpage,long totalnum)
{
l_curpage = currentpage;
l_totalnum = totalnum;

if (currentpage>=0)
{
if (currentpage>=(long)Math.ceil((double)l_totalnum/(double)int_num))
l_curpage = (long)Math.floor((double)l_totalnum/(double)int_num);
else
l_curpage = currentpage;
}
else
{
l_curpage = 0;
}
l_start = l_curpage * int_num;
l_end = l_start + int_num;
if (l_end > l_totalnum)
l_end = l_totalnum;
l_totalpage = (long)Math.ceil((double)l_totalnum/(double)int_num);
}
public long getCurpage()
{
return l_curpage;
}
public long getPrepage()
{
if (l_curpage-1>=0)
{
return l_curpage-1;
}
else
{
return 0;
}
}
public long getNextpage()
{
if (l_curpage+1<=l_totalpage)
{
return l_curpage+1;
}
else
{
return l_totalpage;
}
}
public long getTotalnum()
{
return l_totalnum;
}
public long getTotalpage()
{
return l_totalpage;
}
public long getStart()
{
return l_start;
}
public long getEnd()
{
return l_end;
}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.