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");// 設(shè)置查詢的起始行和查詢條目數(shù)量queryObject.setFirstResult(pager.getStartRow());queryObject.setMaxResults(pager.getRows());return queryObject.list();}Pager: public class Pager {private int totalRows = 100; // 總行數(shù)private int rows = 10; // 每頁顯示的行數(shù)private int page = 1; // 當(dāng)前頁號,從1開始private int totalPage = 5; // 總頁數(shù)private int startRow = 0; // 當(dāng)前頁在數(shù)據(jù)庫中的起始行public Pager() {} ... set/get轉(zhuǎn)載于:https://www.cnblogs.com/jasonhaven/p/7355025.html
總結(jié)
- 上一篇: QWT中Qdial的入门介绍
- 下一篇: 09. 用两个栈实现队列