关于ssm的分页部分代码

2019-05-25 08:38:49 浏览数 (2)

PageObject 以下省略了setter和getter

代码语言:javascript复制
public class PageObject {

    private Integer currentPage = 1;
    private Integer pageSize = 5;

    //为了后面的mapper中limit的运算
    public Integer getStart() {
        return (currentPage-1)*pageSize;
    }


}

PageResult

代码语言:javascript复制
public class PageResult {

    private Integer currentPage=1;//当前页
    private Integer pageSize=5;//每页显示的数据条数
    private Integer totleCount;//总的记录条数。查询数据库得到的数据
    //列表
    private List dataList;

    public PageResult() {

    }

    public PageResult(PageObject pageObject, List list, Integer count ) {

        this.setCurrentPage(pageObject.getCurrentPage());
        this.setPageSize(pageObject.getPageSize());
        this.setDataList(list);
        this.setTotleCount(count);
    }



    //得到总页数
    public Integer getTotlePage() {
        Integer num = 0;

                //可以除尽
        if (totleCount%pageSize==0){

            num=totleCount/pageSize;
        }else{
            //除不尽
            num = totleCount/pageSize   1;
        }
        return num;
    }
   
}

vo

代码语言:javascript复制
public class RuleVo extends PageObject {

    private String ruleName;//用于模糊查询的规则名称


    public String getRuleName() {
        return ruleName;
    }

    public void setRuleName(String ruleName) {
        this.ruleName = ruleName;
    }

    @Override
    public String toString() {
        return "RuleVo{"  
                "ruleName='"   ruleName   '''  
                '}';
    }
}

0 人点赞