您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇内容介绍了“java中List分页的方法有哪些”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
Criteria criteria = new Criteria(); //将dataAuto转成 factoryId brandId seriesId 等查询条件 String dataAuth = ""; TypeCaseHelper.dataAuto(criteria, dataAuth); // 设置分页信息 ExtPager pager = new ExtPager(); Integer startTure = start * pageSize; criteria.setMysqlPageSize(pageSize); criteria.setMysqlStart(startTure); // 排序信息 if (StringUtils.isNotBlank(pager.getDir()) && StringUtils.isNotBlank(pager.getSort())) { criteria.setOrderByClause(pager.getSort() + " " + pager.getDir()); } List<VhlAlarmStatusMgtEntity> listDistinct = getVhlAlarmStatusMgtEntities(vin, faultStatus, confirmStatus, startDateTime, endDateTime, sdf, sdfm, carTypeList, criteria);
对应的分页sql
<select id="selectByExample" parameterType="Criteria" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from status_mgt <where> <if test="condition.carTypeList != null and condition.carTypeList.size() > 0" > and car_type in <foreach collection="condition.carTypeList" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> <if test="condition.startDateTime != null and condition.startDateTime!=''"> and alarm_time >= str_to_date(#{condition.startDateTime,jdbcType=VARCHAR},'%Y-%m-%d %H:%i:%S') </if> <if test="condition.endDateTime != null and condition.endDateTime!=''"> and str_to_date(#{condition.endDateTime,jdbcType=VARCHAR},'%Y-%m-%d %H:%i:%S') >= alarm_time </if> and logic_flag = 1 </where> order by alarm_time desc <if test="mysqlStart != null and mysqlPageSize != null"> limit #{mysqlStart}, #{mysqlPageSize} </if> </select>
Criteria criteria1 = new Criteria(); List<VhlAlarmStatusMgtEntity> listDistinctForCout = getVhlAlarmStatusMgtEntities(vin, faultStatus, confirmStatus, startDateTime, endDateTime, sdf, sdfm, carTypeList, criteria1); Integer count = listDistinctForCout.size(); // 记录总数 Integer pageCount; // 页数 if (count % pageSize == 0) { pageCount = count / pageSize; } else { pageCount = count / pageSize + 1; } int fromIndex; // 开始索引 int toIndex; // 结束索引 if (!pageCount.equals(start+1)) { fromIndex = start * pageSize; toIndex = fromIndex + pageSize; if(toIndex > count){ fromIndex = (start-1) * pageSize; toIndex = count; } } else { fromIndex = start * pageSize; toIndex = count; } List<VhlAlarmStatusMgtEntity> pageList = listDistinctForCout.subList(fromIndex, toIndex);
//开启分页 PageHelper.startPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize)); PageInfo<Map<String, String>> pageInfo = new PageInfo(datalist); HashMap<String, Object> map= new HashMap<>(); map.put("datalist", datalist); map.put("total", pageInfo.getTotal()); map.put("size", pageInfo.getPageSize()); map.put("page", pageInfo.getPageNum());
“java中List分页的方法有哪些”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。