自己写的thymeleaf 和pagehelper整合分页 第一次用thymeleaf也参考了一些博客
controller层
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15@RequestMapping("/searchmenu") public String searchMenu(SearchVo searchVo,Integer pageNum, Integer pageSize,Model model){ //pageNum当前第几页 //pageSize每页有几个 pageNum=pageNum==null?1:pageNum; pageSize=pageSize==null?12:pageSize; PageHelper.startPage(pageNum,pageSize); List<Menu> menuList = menuService.selectBySearchVo(searchVo); PageInfo<Menu> pageInfo = new PageInfo<>(menuList); model.addAttribute("pageInfo", pageInfo); model.addAttribute("searchvo", searchVo); return "menu"; }
html
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50<div class="col-md-6"> 当前第 [[${pageInfo.pageNum}]]页,共 [[${pageInfo.pages}]] 页.一共 [[${pageInfo.total}]] 条记录 </div> <ul class="pagination pull-right no-margin"> <!--首页--> <li th:if="${pageInfo.hasPreviousPage}"> <a th:href="@{/searchmenu(pageNum=1)}">首页</a> </li> <li class="prev" th:if="${pageInfo.hasPreviousPage}"> <a th:href="@{/searchmenu(pageNum=${pageInfo.pageNum-1})}"> <!--上一页 这里报错没关系-> <i class="ace-icon fa fa-angle-double-left"></i> </a> </li> <li th:each="i :${#numbers.sequence(1, pageInfo.pages)}"> <a th:href="@{/searchmenu(pageNum=${i})}"> <!--跳转到某页 --> <!-- 当前页样式为on--> <span th:class="${pageInfo.pageNum == i}? 'on' :''"> <th:block th:text="${i}"></th:block> </span> </a> </li> <li class="next" th:if="${pageInfo.hasNextPage}"> <!--下一页 --> <a th:href="@{/searchmenu(pageNum=${pageInfo.pageNum+1})}"> <i class="ace-icon fa fa-angle-double-right"></i> </a> </li> <li> <!--尾页--> <a th:href="@{/searchmenu(pageNum=${pageInfo.getLastPage()})}">尾页</a> </li> </ul> <div>当前页号:<span th:text="${pageInfo.pageNum}"></span></div> <div>每页条数:<span th:text="${pageInfo.pageSize}"></span></div> <div>起始行号:<span th:text="${pageInfo.startRow}"></span></div> <div>终止行号:<span th:text="${pageInfo.endRow}"></span></div> <div>总结果数:<span th:text="${pageInfo.total}"></span></div> <div>总页数:<span th:text="${pageInfo.pages}"></span></div> <hr /> <div>是否为第一页:<span th:text="${pageInfo.isFirstPage}"></span></div> <div>是否为最后一页:<span th:text="${pageInfo.isLastPage}"></span></div> <div>是否有前一页:<span th:text="${pageInfo.hasPreviousPage}"></span></div> <div>是否有下一页:<span th:text="${pageInfo.hasNextPage}"></span></div> 显示分页信息完毕
最后
以上就是敏感钢铁侠最近收集整理的关于thymeleaf 和pagehelper整合分页的全部内容,更多相关thymeleaf内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复