zoukankan      html  css  js  c++  java
  • 后台集合分页

    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); }
  • 相关阅读:
    VS2019 技巧
    html5-Canvas
    JS动画三剑客——setTimeout、setInterval、requestAnimationFrame
    C# 从1到Core--委托与事件
    ILSpy工具使用
    .NET 表达式计算:Expression Evaluator
    jQuery.globalEval()方法
    jquery的eval的使用
    js中的eval方法
    设计模式速查手册
  • 原文地址:https://www.cnblogs.com/maocai2018/p/10117148.html
Copyright © 2011-2022 走看看