📄 pageinfo.java
字号:
package com.qhit.kgdyffje.service;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.qhit.kgdyffje.common.common;
import com.qhit.kgdyffje.dao.DAODataBean;
/**
* 页面分页处理类
* @author Administrator
*
*/
public class pageInfo {
private int recordTotal; //总的记录数
private int pageTotal; //总页面数
private int pageRecordNum=10; //每页记录数
private int currentPage=1; //当前页数
private List pageRecordList=new ArrayList(); //总的记录集合
private boolean hasNextPage; //判断是否有下一页
private boolean hasPreviousPage; //判断是否有上一页
private int startLocation; //开始位置
private int endLocation; //结束位置
public int getStartLocation() {
return startLocation;
}
public int getEndLocation() {
return endLocation;
}
public int getRecordTotal() {
return recordTotal;
}
//设置总记录数
public void setRecordTotal(int recordTotal) {
this.recordTotal = recordTotal;
//设置总页面数
setPageTotal();
//判断是否有上一页和下一页
isNextPreviousPage();
}
/**
* 设置总页面数
*/
public void setPageTotal(){
int temp=this.recordTotal%this.pageRecordNum;
if(0!=temp){
this.pageTotal=this.recordTotal/this.pageRecordNum+1;
}else{
this.pageTotal=this.recordTotal/this.pageRecordNum;
}
}
public int getPageTotal() {
return pageTotal;
}
/**
* 设置当前页
*/
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getCurrentPage() {
return currentPage;
}
/**
* 判断是否有上一页和下一页
*/
public void isNextPreviousPage(){
if(this.currentPage>1){
this.hasPreviousPage=true;
}else{
this.hasPreviousPage=false;
}
if(this.currentPage<this.pageTotal){
this.hasNextPage=true;
}else{
this.hasNextPage=false;
}
}
/*
* 返回查询出的数据集
*/
public List getPageRecordList() {
return pageRecordList;
}
//设置总的记录数
public void setPageRecordList(List pageRecordList) {
this.pageRecordList = pageRecordList;
}
//判断是否有下一页
public boolean isHasNextPage() {
return this.hasNextPage;
}
//判断是否有上一页
public boolean isHasPreviousPage() {
return this.hasPreviousPage;
}
/**
*
* @return int 返回每页显示的条数
*/
public int getPageRecordNum() {
return this.pageRecordNum;
}
//设置页面记录数
public void setPageRecordNum(int pageRecordNum) {
this.pageRecordNum = pageRecordNum;
}
/*
* 分页的具体方法
*/
// public void pageInfoMethod(){
// //清空页面记录集合
// this.pageRecordList.clear();
// if(null==this.sql||"".equals(sql)){
// sql="select * from kgdyffje.fwinfo order by udate desc";
// }
// System.out.println("-----------sql----");
// System.out.println("分页字符串:"+sql);
// System.out.println("----------sql-----");
// DAODataBean ddb=new DAODataBean();
// ResultSet rs = ddb.getResult(sql);
// //设置总记录数
// this.setRecordTotal(rs);
// //设置页面总数
// this.setPageTotal();
// //判断上一页下一页
// this.isNextPreviousPage();
// //游标定位
// try {
// if(this.currentPage==1){
// rs.beforeFirst();
// }else{
// rs.absolute((this.currentPage-1)*this.pageRecordNum);
// }
// int count=0;
// while(rs.next()&&count<this.pageRecordNum){
// HouseInfoBean hib=new HouseInfoBean();
// hib.setFwid(rs.getInt("fwid"));
// hib.setFwxx(rs.getString("fwxx"));
// hib.setJdid(rs.getInt("jdid"));
// hib.setLxid(rs.getInt("lxid"));
// hib.setLxr(rs.getString("lxr"));
// hib.setQxid(rs.getInt("qxid"));
// hib.setShi(rs.getInt("shi"));
// hib.setTelephone(rs.getString("telephone"));
// hib.setTing(rs.getInt("ting"));
// hib.setTitle(rs.getString("title"));
// System.out.println("-------------");
// System.out.println(common.parseDate(rs.getString("udate")));
// System.out.println("-------------");
// hib.setUdate(common.formatDate(common.parseDate(rs.getString("udate"))));
// hib.setUserid(rs.getInt("userid"));
// hib.setZj(rs.getDouble("zj"));
// this.pageRecordList.add(hib);
// count++;
// }
// } catch (SQLException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -