zoukankan      html  css  js  c++  java
  • 分页技巧_分析分页的实现步骤_分析页面中显示的分页信息

    分页技巧__分析分页的实现步骤1__分析页面中显示的分页信息

    主题列表分页

    回复列表

    Jsp显示数据,数据找Action拿,Action调用Service去做真正的去数据库中计算某种数据

    Jsp中找出要显示哪些,Action为jsp准备,哪些需要Service就添加

    第一步:分析页面中需要显示什么数据

    ======================= 本页的数据列表 ========================

    <s:iterator value="%{recordList}">

      ...

    </s:iterator>

    ======================= 分页信息 ========================

    页次:${currentPage}/${pageCount}页   

    每页显示:${pageSize}条   

    总记录数:${recordCount}条  

    <s:iterator begin="%{beginPageIndex}" end="%{endPageIndex}" var="num">

      ...

    </s:iterator>

    转到(下拉列表):

    <select onchange="gotoPage(this.value)">

      <s:iterator begin="1" end="%{pageCount}" var="num">

        <option value="${num}">${num}</option>

      </s:iterator>

    </select>

    <script>

      function gotoPage( pageNum ){

        window.location.href = "url?pageNum=" + pageNum;

      }

    </script>

    ======== 页面中需要显示的数据 ===========

    recordList本页的数据列表

    currentPage当前页

    pageCount总页数

    pageSize每页显示多少条

    recordCount总记录数

    beginPageIndex页码列表的开始索引

    endPageIndex页码列表的结束索引

    PageBean.java

    /**
     * 分页功能中的一页的信息
     */
    public class PageBean {
        //指定的或是页面参数
        private int currentPage;    // 当前页
        private int pageSize;        // 每页显示多少条
        
        //查询数据库
        private int recordCount;    // 总记录数
        private List recordList;    // 本页的数据列表
        
        //计算
        private int pageCount;        // 总页数
        private int beginPageIndex;    // 页码列表的开始索引
        private int endPageIndex;    // 页码列表的结束索引
    
        /**
         * 只接受前四个必要的属性,会自动的计算出其他3个属性的值
         * @param currentPage    当前页
         * @param pageSize        每页显示多少条
         * @param recordCount    总记录数
         * @param recordList    本页的数据列表
         */
        public PageBean(int currentPage, int pageSize, int recordCount, List recordList) {
            this.currentPage = currentPage;
            this.pageSize = pageSize;
            this.recordCount = recordCount;
            this.recordList = recordList;
            //只接受前四个必要的属性,会自动的计算出其他3个属性的值
            //计算总页码
            pageCount = (recordCount + pageSize - 1) / pageSize;
            
            //TODO 计算beginPageIndex 和endPageIndex
        }
        
        public List getRecordList() {
            return recordList;
        }
        public void setRecordList(List recordList) {
            this.recordList = recordList;
        }
        public int getCurrentPage() {
            return currentPage;
        }
        public void setCurrentPage(int currentPage) {
            this.currentPage = currentPage;
        }
        public int getPageCount() {
            return pageCount;
        }
        public void setPageCount(int pageCount) {
            this.pageCount = pageCount;
        }
        public int getPageSize() {
            return pageSize;
        }
        public void setPageSize(int pageSize) {
            this.pageSize = pageSize;
        }
        public int getRecordCount() {
            return recordCount;
        }
        public void setRecordCount(int recordCount) {
            this.recordCount = recordCount;
        }
        public int getBeginPageIndex() {
            return beginPageIndex;
        }
        public void setBeginPageIndex(int beginPageIndex) {
            this.beginPageIndex = beginPageIndex;
        }
        public int getEndPageIndex() {
            return endPageIndex;
        }
        public void setEndPageIndex(int endPageIndex) {
            this.endPageIndex = endPageIndex;
        }
    }
  • 相关阅读:
    hdu 2132 An easy problem
    ACM暑假培训宣讲稿
    hdu Lovekey(水题)
    windows 下c++编译
    semantic
    could not open XXX permission denied
    sv_target_output dx11
    hlsl 的tex函数
    effect state dx11
    cg 到hlsl的转换
  • 原文地址:https://www.cnblogs.com/justdoitba/p/7965564.html
Copyright © 2011-2022 走看看