SSH:分页实现
StudentAction:
public class StudentAction extends ActionSupport {// 初始化下拉列表@Resourceprivate StudentService studentService;.... .... set/getStudentService:
public class StudentService {@Resourceprivate StudentDAO studentDAO;public List<Student> findByPager(Pager pager) {return studentDAO.findByPage(pager);}StudentDao
@Transactional public class StudentDAO {public List<Student> findByPage(Pager pager) {Query queryObject = getCurrentSession().createQuery("from Student");// 設置查詢的起始行和查詢條目數量queryObject.setFirstResult(pager.getStartRow());queryObject.setMaxResults(pager.getRows());return queryObject.list();}Pager: public class Pager {private int totalRows = 100; // 總行數private int rows = 10; // 每頁顯示的行數private int page = 1; // 當前頁號,從1開始private int totalPage = 5; // 總頁數private int startRow = 0; // 當前頁在數據庫中的起始行public Pager() {} ... set/get轉載于:https://www.cnblogs.com/jasonhaven/p/7355025.html
總結
- 上一篇: QWT中Qdial的入门介绍
- 下一篇: 09. 用两个栈实现队列