In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what are the methods of List pagination in java". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. According to the paging parameters of input parameters, sql query paging Criteria criteria = new Criteria (); / / convert dataAuto to factoryId brandId seriesId and other query conditions String dataAuth = ""; TypeCaseHelper.dataAuto (criteria, dataAuth); / / set paging information ExtPager pager = new ExtPager (); Integer startTure = start * pageSize; criteria.setMysqlPageSize (pageSize); criteria.setMysqlStart (startTure) / / sorting information if (StringUtils.isNotBlank (pager.getDir ()) & & StringUtils.isNotBlank (pager.getSort () {criteria.setOrderByClause (pager.getSort () + "+ pager.getDir ());} List listDistinct = getVhlAlarmStatusMgtEntities (vin, faultStatus, confirmStatus, startDateTime, endDateTime, sdf, sdfm, carTypeList, criteria)
Corresponding paging sql
Select from status_mgt and car_type in # {item} and alarm_time > = str_to_date (# {condition.startDateTime,jdbcType=VARCHAR},'% Y-%m-%d% HRV% iRV% S') and str_to_date (# {condition.endDateTime,jdbcType=VARCHAR} '% Y-%m-%d% HRV% iRV% S') > = alarm_time and logic_flag = 1 order by alarm_time desc limit # {mysqlStart}, # {mysqlPageSize} 2. Paging all list according to paging parameters Criteria criteria1 = new Criteria (); List listDistinctForCout = getVhlAlarmStatusMgtEntities (vin, faultStatus, confirmStatus, startDateTime, endDateTime, sdf, sdfm, carTypeList, criteria1); Integer count = listDistinctForCout.size (); / / Total number of records Integer pageCount; / / if (count% pageSize = 0) {pageCount = count / pageSize;} else {pageCount = count / pageSize + 1 } int fromIndex; / / start index int toIndex; / / end index 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 pageList = listDistinctForCout.subList (fromIndex, toIndex); 3.PageHelper pagination / / Open paging PageHelper.startPage (Integer.parseInt (pageNum), Integer.parseInt (pageSize)); PageInfo pageInfo = new PageInfo (datalist); HashMap map= new HashMap () Map.put ("datalist", datalist); map.put ("total", pageInfo.getTotal ()); map.put ("size", pageInfo.getPageSize ()); map.put ("page", pageInfo.getPageNum ()); "what are the methods of List pagination in java". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.