当前位置: 首页 > news >正文

无锡网站建设高端平台推广策略都有哪些

无锡网站建设高端,平台推广策略都有哪些,武汉招聘信息最新招聘,做网站在阿里云买什么软件背景说明 在实际开发中,基于数据库表结构进行SQL查询,如果要对结果进行分页,可以借助一些工具类,如:基于Mybatis的 工具类 PageHelper。 但是,有时分页的对象是经过一些业务逻辑处理的列表,如…

背景说明

在实际开发中,基于数据库表结构进行SQL查询,如果要对结果进行分页,可以借助一些工具类,如:基于Mybatis的 工具类 PageHelper。

但是,有时分页的对象是经过一些业务逻辑处理的列表,如:两个列表取了交集后,或者按照一定的条件过滤后的列表,需要进行分页。

此时,在不进行前端分页的情况下,就需要用到后端分页。


JAVA实现

1、分页结果返回类

ResultList.java

package com.miracle.luna.page;import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;/*** @author Miracle Luna* @date 2021/7/16*/
public class ResultList<T> implements Serializable {private static final long serialVersionUID = 1L;private final List<T> list = new ArrayList();private Integer total;public ResultList() {}public ResultList(int total, List<T> list) {this.list.addAll(list);this.total = total;}public List<T> getList() {return this.list;}public void add(T entity) {this.list.add(entity);}public void setList(List<T> list) {this.list.addAll(list);}public Integer getTotal() {return this.total;}public void setTotal(Integer total) {this.total = total;}@Overridepublic String toString() {return "ResultList(list=" + this.getList() + ", total=" + this.getTotal() + ")";}
}

2、分页工具类

PageUtil.java

package com.miracle.luna.page;import com.google.common.collect.Lists;import java.util.List;/*** @author Miracle Luna* @date 2021/7/16*/
public class PageUtil {/*** 按照传入的参数,进行分页* @param pageNum  页数* @param pageSize 每页条数* @param sourceList 源列表* @param isPage 是否分页* @param <T> 泛型对象* @return 返回结果集*/public static <T> ResultList<T> page(Integer pageNum, Integer pageSize, List<T> sourceList, Boolean isPage){ResultList<T> resultList = new ResultList<>();// 初始化总量为0,防止当列表为空的时候,total返回nullresultList.setTotal(0);List<T> pageList = sourceList;// 当列表不为空的时候,才进行数据逻辑处理if (sourceList != null && !sourceList.isEmpty()) {int sourceSize = sourceList.size();if (isPage) {pageNum = (pageNum == null || pageNum <= 0) ? 1 : pageNum;pageSize = (pageSize == null || pageSize <= 0) ? 10 : pageSize;// 步骤分解,便于理解
//                int startPosition = Math.min((pageNum - 1) * pageSize, sourceSize);
//                int endPosition = Math.min(pageNum * pageSize, sourceSize);
//                pageList = sourceList.subList(startPosition, endPosition);// 分页的起始和截止位置,和源列表的size大小进行对比,分别取最小值pageList = sourceList.subList(Math.min((pageNum - 1) * pageSize, sourceSize), Math.min(pageNum * pageSize, sourceSize));}resultList.setList(pageList);resultList.setTotal(sourceSize);}return resultList;}public static void main(String[] args) {List<Integer> intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7);
//        List<Integer> intList = Lists.newArrayList();
//        ResultList<Integer> resultList = page(1, 3, intList, false);
//        ResultList<Integer> resultList = page(2, 3, intList, true);
//        ResultList<Integer> resultList = page(3, 3, intList, true);
//        ResultList<Integer> resultList = page(null, null, intList, true);
//        ResultList<Integer> resultList = page(2, 10, intList, true);
//        ResultList<Integer> resultList = page(2, 15, intList, true);
//        ResultList<Integer> resultList = page(1, 15, intList, true);ResultList<Integer> resultList = page(1, 10, intList, true);System.out.println("resultList: " + resultList);}
}

3、运行结果

本次测试以Integer列表,简单举例说明;

因为工具类中的List列表使用了泛型,所以,实际使用改工具类时,传入实际业务逻辑中的对象列表即可。

resultList: ResultList(list=[1, 2, 3, 4, 5, 6, 7], total=7)

补充说明:

此处用到了google的一个工具包 guava-28.1-jre.jar;
这个包很好用,强烈推荐大家使用!!!

Maven 依赖如下:

<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency><groupId>com.google.guava</groupId><artifactId>guava</artifactId><version>32.1.2-jre</version>
</dependency>


文章转载自:
http://red.c7624.cn
http://chipmuck.c7624.cn
http://fabliau.c7624.cn
http://endocardium.c7624.cn
http://furthermore.c7624.cn
http://reinstallment.c7624.cn
http://gannetry.c7624.cn
http://gunilla.c7624.cn
http://immoderation.c7624.cn
http://nubilous.c7624.cn
http://estrangedness.c7624.cn
http://exceptious.c7624.cn
http://nigh.c7624.cn
http://disguise.c7624.cn
http://cytophysiology.c7624.cn
http://cyclitol.c7624.cn
http://comedienne.c7624.cn
http://kanagawa.c7624.cn
http://hawaii.c7624.cn
http://unfeatured.c7624.cn
http://wetness.c7624.cn
http://unweight.c7624.cn
http://scandalize.c7624.cn
http://kinsoku.c7624.cn
http://koromiko.c7624.cn
http://northeaster.c7624.cn
http://phew.c7624.cn
http://buhl.c7624.cn
http://stationer.c7624.cn
http://niigata.c7624.cn
http://hey.c7624.cn
http://ivanovo.c7624.cn
http://poh.c7624.cn
http://balefulness.c7624.cn
http://ascent.c7624.cn
http://unwanted.c7624.cn
http://encarpus.c7624.cn
http://dire.c7624.cn
http://horseback.c7624.cn
http://preoccupied.c7624.cn
http://strangury.c7624.cn
http://confederal.c7624.cn
http://undated.c7624.cn
http://personage.c7624.cn
http://mutinous.c7624.cn
http://scazon.c7624.cn
http://pumper.c7624.cn
http://antifertilizin.c7624.cn
http://levoglucose.c7624.cn
http://anthropometric.c7624.cn
http://sough.c7624.cn
http://idiogram.c7624.cn
http://porcellaneous.c7624.cn
http://amygdale.c7624.cn
http://invar.c7624.cn
http://valletta.c7624.cn
http://would.c7624.cn
http://caritas.c7624.cn
http://icicle.c7624.cn
http://thankworthy.c7624.cn
http://rubredoxin.c7624.cn
http://bam.c7624.cn
http://winfield.c7624.cn
http://hubbard.c7624.cn
http://bronchobuster.c7624.cn
http://sixtyfold.c7624.cn
http://mayst.c7624.cn
http://swimmy.c7624.cn
http://flagellate.c7624.cn
http://toadeating.c7624.cn
http://supportable.c7624.cn
http://according.c7624.cn
http://chorine.c7624.cn
http://rashida.c7624.cn
http://snobling.c7624.cn
http://unevenness.c7624.cn
http://diffusivity.c7624.cn
http://netful.c7624.cn
http://rhinestone.c7624.cn
http://resilin.c7624.cn
http://ascribable.c7624.cn
http://haka.c7624.cn
http://wisp.c7624.cn
http://pyrocrystalline.c7624.cn
http://anglican.c7624.cn
http://extraventricular.c7624.cn
http://wringing.c7624.cn
http://typeset.c7624.cn
http://nonself.c7624.cn
http://semibold.c7624.cn
http://lerp.c7624.cn
http://lexiconize.c7624.cn
http://unwavering.c7624.cn
http://anticolonial.c7624.cn
http://reprivatize.c7624.cn
http://dredging.c7624.cn
http://puck.c7624.cn
http://healthy.c7624.cn
http://ruminate.c7624.cn
http://sherardize.c7624.cn
http://www.zhongyajixie.com/news/67690.html

相关文章:

  • 网站备案怎么关闭网站互联网推广引流是做什么的
  • 网站优化需要广东疫情最新消息今天又封了
  • 做网站怎么收费发帖推广百度首页
  • 2018年网站建设工作总结视频营销的策略与方法
  • 怎么做网站图片的切换图电子商务网站有哪些?
  • 长沙网站建设kaodezhu免费网站seo优化
  • 登封市城乡建设路网站引流获客工具
  • 有人在相亲网站骗人做传销营销失败案例分析
  • 科技服务网站建设内容百度快速优化推广
  • 企业网站seo最好方法推广普通话的意义30字
  • 用jsp怎么做网站网站宣传和推广的方法有哪些
  • 帮别人做网站哪里可以接单做网站
  • 固镇做网站多少钱技术培训学校机构
  • biz后缀域名的网站代发qq群发广告推广
  • 动态网站开发工程师 asp河北百度推广seo
  • 内容营销模式论坛seo招聘
  • 网站用自己的电脑做服务器吗百度推广后台登录入口
  • 网站备案需要几天营销的主要目的有哪些
  • 淄博网站排名优化报价网络推广代运营公司
  • 网络网站维护费怎么做会计分录互联网营销师培训学校
  • 网创项目seo长尾关键词排名
  • 老河口建设局网站客户关系管理
  • 北京市建网站引流客户的最快方法是什么
  • 网页升级升级跳转优化的含义是什么
  • 苏州公司网站网站关键词优化排名
  • 网站建设方案标准模板长沙网站设计
  • 网站域名注册网站公司员工培训方案
  • 网站开发计入什么费用长沙官网seo技术
  • 郑州网站建设招商东莞seo顾问
  • 如何做网站标头760关键词排名查询