中职示范校建设专题网站,长尾关键词排名系统,一台服务器可以做几个网站,网站对不同分辨率pageInfo的属性 pageNum#xff1a;当前页 pageSize#xff1a;页面数据量 startRow#xff1a;当前页首条数据为总数据的第几条 endRow#xff1a;当前页最后一条数据为总数据的第几条 total#xff1a;总数据量 pages#xff1a;总页面数 listPage{}结果集 reasonable … pageInfo的属性 pageNum当前页 pageSize页面数据量 startRow当前页首条数据为总数据的第几条 endRow当前页最后一条数据为总数据的第几条 total总数据量 pages总页面数 listPage{}结果集 reasonable 合理化分页 pageSizeZero页面是否为空 prePage前一页 nextPage下一页 isFirstPage是否是第一页 isLastPage是否是最后一页 hasPreviousPage是否存在上一页 hasNextPage是否存在下一页 navigatePages导航页码数 navigateFirstPage导航条上第一页 navigateLastPage导航条最后一页 navigatepageNums所有导航号列表 1. pom !--分页插件--dependencygroupIdcom.github.pagehelper/groupIdartifactIdpagehelper/artifactIdversion5.1.10/version/dependencydependencygroupIdcom.github.pagehelper/groupIdartifactIdpagehelper-spring-boot-autoconfigure/artifactIdversion1.4.1/version/dependencydependencygroupIdcom.github.pagehelper/groupIdartifactIdpagehelper-spring-boot-starter/artifactIdversion1.4.1/version/dependency 2. boot配置文件
pagehelper:helper-dialect: mysqlreasonable: truesupport-methods-arguments: trueparams: countcountSql 3. sql语句
查询所有
4. 控制层
RequestParam(value pn, defaultValue 1)请求的参数为pn 默认值为1
PageHelper.startPage(pn, 3)设置 页面大小
model.addAttribute将pageInfo放入model中期中包含了所有的分页的属性以及查询的数据 public String dynamic_table(RequestParam(value pn, defaultValue 1) Integer pn, Model model){PageHelper.startPage(pn, 3);//页面大小为3 这个要放在查询语句上面 才起作用ListUser userList userService.getAllUsers();model.addAttribute(users, userList);userList.forEach(System.out::println);
// 添加分页PageInfoUser usertPageInfo new PageInfoUser(userList);System.out.println(usertPageInfo);model.addAttribute(pageInfo, usertPageInfo);return table/dynamic_table;}
5. 页面 div classrow-fluiddiv classspan6div classdataTables_info iddynamic-table_info当前页 [[${pageInfo.pageNum}]] 总计 [[${pageInfo.pages}]] 共 [[${pageInfo.total}]]条/divdiv classdataTables_paginate paging_bootstrap paginationulli classprev th:if${pageInfo.hasPreviousPage} a th:href{/dynamic_table(pn1)}首页/a/lili classpreva th:if${pageInfo.hasPreviousPage} th:href{/dynamic_table(pn${pageInfo.prePage})}上一页/a/lili th:class${num pageInfo.pageNum? active : } th:eachnum:${#numbers.sequence(1, pageInfo.pages)}a th:href{/dynamic_table(pn${num})}[[${num}]]/a/lili classnexta th:if${pageInfo.hasNextPage} th:href{/dynamic_table(pn${pageInfo.nextPage})}下一页 /a/lili classnexta th:if${pageInfo.hasNextPage} th:href{/dynamic_table(pn${pageInfo.pages})}尾页 /a/li/ul/div/div/div 点击第一页不存在上一页首页和上一页禁用标签不显示 中间页码存在上一页首页和上一页显示 在最后一页不存在下一页尾页和下一页不显示