zoukankan      html  css  js  c++  java
  • SSH:分页实现

    StudentAction:

    public class StudentAction extends ActionSupport {
    
    
    	// 初始化下拉列表
    	@Resource
    	private StudentService studentService;
    
    ....
    ....
    set/get
    

    StudentService:

    public class StudentService {
    	@Resource
    	private 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



  • 相关阅读:
    倒下
    我还能相信谁

    工作这点事
    人,这东西
    祝福
    路,公车和鞋子
    那片海
    document.querySelector bug All In One
    js logical or assignment bug All In One
  • 原文地址:https://www.cnblogs.com/jasonhaven/p/7355025.html
Copyright © 2011-2022 走看看