关于分页的。。
/**
* RowBounds
*/
public class RowBounds extends org.apache.ibatis.session.RowBounds implements Serializable{
private int offset = NO_ROW_OFFSET;
private int limit = NO_ROW_LIMIT;
private int pageNumber = 0;
/**
*
*/
public RowBounds() {
super();
}
/**
* @param offset
* @param limit
*/
public RowBounds(int pageNumber, int pageSize) {
this.limit = pageSize;
this.pageNumber = pageNumber;
this.offset = (pageNumber - 1)*pageSize;
}
public int getLimit() {
return limit;
}
public int getOffset() {
return offset;
}
public int getPageNumber() {
return this.pageNumber;
}
}
/**
* Pagination
*/
public class Pagination implements Serializable{
/**
*
*/
private static final long serialVersionUID = -6966750556299243546L;
private int total;
private List data;
private RowBounds rowBounds;
public Pagination()
{
}
public Pagination(RowBounds rowBounds, int total)
{
this.total = 0;
this.rowBounds = new RowBounds(rowBounds.getPageNumber(), rowBounds.getLimit());
this.total = total;
}
public Pagination(RowBounds rowBounds, int total, List data)
{
this.total = 0;
this.rowBounds = new RowBounds(rowBounds.getPageNumber(), rowBounds.getLimit());
this.total = total;
setData(data);
}
public RowBounds getRowBounds()
{
return new RowBounds(this.rowBounds.getPageNumber(), this.rowBounds.getLimit());
}
public List getData()
{
return this.data;
}
public void setData(List data)
{
this.data = data;
if ((data != null) && (data.size() > this.total))
throw new FrameworkException("data.size>total.please check total.");
}
public int getTotal()
{
return this.total;
}
public int getPageTotal()
{
int size = this.rowBounds.getLimit();
return (int)Math.ceil(this.total * 1.0D / size);
}
}
public class PagingCondition extends Condition {
protected int pageIndex;
protected int pageSize;
/**
* @return the pageIndex
*/
public int getPageIndex() {
return pageIndex;
}
/**
* @param pageIndex the pageIndex to set
*/
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
}
/**
* @return the pageSize
*/
public int getPageSize() {
return pageSize;
}
/**
* @param pageSize the pageSize to set
*/
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
/**
* 构造分页查询条件
* @return
*/
public RowBounds buildBounds(){
return new RowBounds(this.pageIndex,this.pageSize);
}
}

浙公网安备 33010602011771号