分页逻辑 六

来源:互联网 发布:软件测试社会实践报告 编辑:程序博客网 时间:2024/05/16 14:15

  进行全查询时候 对分页进行的相关设置

 //设置分页的相关信息
        String pageSize = aRequest.getParameter("pageSize");
        String currentPage  = aRequest.getParameter("pageNumber");
        jsonObj = paging(pageSize, currentPage, jsonObj);

 

 

   private JSONObject paging(String pageSize, String currentPage, JSONObject sJson) throws JSONException
    {
        if (null != pageSize && !"".equals(pageSize.trim()) && null != currentPage && !"".equals(currentPage.trim()))
        {
            int currentPageInt = Integer.parseInt(currentPage.trim());
            int pageSizeInt = Integer.parseInt(pageSize.trim());
            sJson.put("ROWNUM_LOW",(currentPageInt-1)*pageSizeInt+1);
            sJson.put("ROWNUM_HIGH",pageSizeInt*currentPageInt);
        }
        else
        {
            sJson.put("ROWNUM_LOW",CheckConstant.DEFAULT_FIRST_RECORD_INDEX);
            sJson.put("ROWNUM_HIGH",CheckConstant.DEFAULT_PAGE_SIZE);
        }
        return sJson;
    }

原创粉丝点击