Paged SQL
Select top number of records to display per page * from table name where primary key not in (select Top (number of records per page * (current page-1)) primary key from table name)
Select Top 5 * from UserInfo where ID not in (select Top (pno-1) with ID from userinfo)
Max pages
Total Records/pages per page if divisible, the maximum number of pages is the result,
If not divisible, the maximum number of pages is the result +1
If the total is 29, each page shows 5, the result is 29/5+1
If the total is 25, each page shows 5, the result is 25/5
Total number of data records
1. Use aggregate functions count queries Total
Select COUNT (primary key) from table name
2. Query all records, add to a collection, and use the. Size () method to get the total
Pagination Template
Property
1. Total Records count
2. Number of records displayed per page custom
3. Current page Dynamic acquisition
4. Maximum pages total record/number of records displayed per page
The pagination class written in the Help class
Package com.zuxia.util;
Import java.util.List;
public class Pagemodel<t> {
Define the current page number
private int pageno=1;
Define Display records per page
private int pagesize=5;
Number of bars in the total bar record
private int count;
Defines the collection of saved numbers
Private list<t> all;
/**
*
* Home
* @return
* */
public int GetIndex ()
{
return 1;
}
/**
* Previous Page
* @return
* */
public int Getprepage ()
{
int prvpage=pageno-1;
if (Prvpage <1)
{
prvpage=1;
}
return prvpage;
}
/**
* Last Page
* @return
* */
public int gettotal ()
{
int totablpage;
if (this.count%pagesize==0)
{
Totablpage=count/pagesize;
}
else{
Totablpage=count/pagesize;
}
return totablpage;
}
/**
* Next Page
* @return
* */
public int Getnextpage ()
{
int nextpage=pageno+1;
if (Nextpage>this.gettotal ())
{
Nextpage=this.gettotal ();
}
return Getnextpage ();
}
public int Getpageno () {
return pageno;
}
public void Setpageno (int pageno) {
This.pageno = PageNo;
}
public int getpagesize () {
return PageSize;
}
public void setpagesize (int pageSize) {
PageSize = PageSize;
}
public int GetCount () {
return count;
}
public void SetCount (int count) {
This.count = count;
}
Public List GetAll () {
return all;
}
public void SetAll (List all) {
This.all = ALL;
}
Public Pagemodel () {
}
}
Templates for the Java paging model