1.PageBean
/**
* 这是一个用于封装了分页的数据
* 包含:
* 该页的学生集合数据
* 总的记录数
* 总的页数
* 当前页
* 每页显示的记录数
* @author acer
*
*/
public class PageBean<T> {
private int currentPage;//当前页
private int totalPage;//总页数
private int pageSize;//每页的记录数
private int totalSize;//总的记录数
private List<T> list;//当前页的学生集合
public int getCurrentPage() {
return currentPage;
}
注意给出setter getter方法
2.Dao接口
List<Student> findStudentByPage(int currentPage) throws SQLException;
/**
* 查询总的学生记录数
*/
int findCount() throws SQLException;
3.Dao实现
@Override
public List<Student> findStudentByPage(int currentPage) throws SQLException {
String sql = "select * from stus limit ? offset ?";
QueryRunner runner = new QueryRunner(JDBCUtil02.getDataSouece());
return runner.query(sql, new BeanListHandler<Student>(Student.class),PAGE_SIZE,(currentPage-1)*PAGE_SIZE);
}
@Override
publ