• 后台集合分页


    public ApiResult getState(@FormParam("deviceType") int deviceType, @FormParam("precinctId") String precinctId,
                                  @FormParam("deviceName") String deviceName, @FormParam("onLine") String onLine,
                                  @FormParam("pageNo") int pageNo, @FormParam("pageSize") int pageSize) {
    //根据条件获取到的集合 List
    <DeviceStatePojoVo> state = deviceMonitorService.getState(deviceType, precinctId, deviceName, onLine); List<DeviceStatePojoVo> stateList = null; int length = state.size(); if (length > 0) { //默认 int startIndex = 0; int endIndex = 10; int no = 1; int size = 10; if (pageSize > 0 && pageSize <= length) { size = pageSize; } int pages = length / size; if (length > pages * size) { pages += 1; //页数 } if (pageNo > 0 && pageNo <= pages) { no = pageNo; } else { no = 1; } startIndex = (no - 1) * size; endIndex = no * size; if (endIndex > length) {//防止下标越界 endIndex = length; } stateList = state.subList(startIndex, endIndex); //两个值都是下标 } PageUtil pageUtil = new PageUtil(state.size(), stateList); return new ApiResult(ApiCode.SUCCESS, pageUtil); }
  • 相关阅读:
    UVA 221
    A Typical Homework(学生信息管理系统)
    追踪电子表格中的单元格
    浮点数!!!(摘)
    poj 3158kickdown
    循环小数 UVa202
    Unix is 命令
    W
    V
    完美世界 字符串倒置输出
  • 原文地址:https://www.cnblogs.com/maocai2018/p/10117148.html
Copyright © 2020-2023  润新知