springboot+thymeleaf 纯后台渲染偷懒版分页

Page<PostEntity> postEntities= postService.findAllByPage(0,10);
model.addAttribute("posts",postEntities.getContent());
int totalPage=postEntities.getTotalPages();
int nowPage=postEntities.getPageable().getPageNumber()+1;
int prePage=nowPage>2?nowPage-1:0;
int nextPage=nowPage<totalPage?nowPage+1:0;
model.addAttribute("totalPage",totalPage);
model.addAttribute("nowPage",nowPage);
model.addAttribute("prePage",prePage);
model.addAttribute("nextPage",nextPage);
return render("index");
}
private String homeInfo(Model model) {
Page<PostEntity> postEntities= postService.findAllByPage(0,10);
model.addAttribute("posts",postEntities.getContent());
int totalPage=postEntities.getTotalPages();
int nowPage=postEntities.getPageable().getPageNumber()+1;
int prePage=nowPage>2?nowPage-1:0;
int nextPage=nowPage<totalPage?nowPage+1:0;
model.addAttribute("totalPage",totalPage);
model.addAttribute("nowPage",nowPage);
model.addAttribute("prePage",prePage);
model.addAttribute("nextPage",nextPage);
return render("index");
}
<div style="text-align: center">
<a class="pure-button" href="/">首页</a>
<a class="pure-button" th:if="${prePage != 0}" th:href="@{'/page/'+${prePage}}">上一页</a>
<a class="pure-button" th:if="${nextPage != 0}" th:href="@{'/page/'+${nextPage}}">下一页</a>
<a class="pure-button" th:href="@{'/page/'+${totalPage}}">尾页</a>
</div>
<!--分页-->
<div style="text-align: center">
<a class="pure-button" href="/">首页</a>
<a class="pure-button" th:if="${prePage != 0}" th:href="@{'/page/'+${prePage}}">上一页</a>
<a class="pure-button" th:if="${nextPage != 0}" th:href="@{'/page/'+${nextPage}}">下一页</a>
<a class="pure-button" th:href="@{'/page/'+${totalPage}}">尾页</a>
</div>
springboot+thymeleaf 纯后台渲染偷懒版分页的更多相关文章
- springboot thymeleaf ----服务端渲染html
一. 引用命名空间 <html xmlns:th="http://www.thymeleaf.org"> 不这么写 html标签没闭合会报错 二.实际内容在../sta ...
- springboot+thymeleaf+pageHelper带条件分页查询
html层 <div> <a class="num"><b th:text="'共 '+ ${result.resultMap['pages ...
- layui表格数据渲染SpringBoot+Thymeleaf返回的数据时报错(Caused by: org.attoparser.ParseException: Could not parse as expression: ")
layui table渲染数据时报错(Caused by: org.attoparser.ParseException: Could not parse as expression: ") ...
- highcharts 结合phantomjs纯后台生成图片系列二之php2
上篇文章中介绍了phantomjs的使用场景,方法. 本篇文章详细介绍使用php,highcharts 结合phantomjs纯后台生成图片.包含一步步详细的php代码 一.highcharts 结合 ...
- highcharts 结合phantomjs纯后台生成图片系列二之php
上篇文章中介绍了phantomjs的使用场景,方法.本篇文章详细介绍使用php,highcharts 结合phantomjs纯后台生成图片. 一.准备: 下载phantomjs解析插件,从 highc ...
- highcharts 结合phantomjs纯后台生成图片
highcharts 结合phantomjs纯后台生成图片 highcharts 这个图表展示插件我想大家应该都知道,纯javascript编写,相比那些flash图表插件有很大的优势,至少浏览器不用 ...
- 原生js版分页插件
之前我在自己的博客里发表了一篇用angularJs自定义指令实现的分页插件,今天简单改造了一下,改成了原生JavaScript版本的分页插件,可以自定义一些简单配置,特此记录下来.如有不足之处,欢迎指 ...
- 一款基于SpringBoot+SpringSecurity的后台管理系统,强烈推荐
简介 Base Admin一套简单通用的后台管理系统,主要功能有:权限管理.菜单管理.用户管理,系统设置.实时日志,API加密,以及登录用户修改密码.配置个性菜单等. 技术栈 前端:Layui 后端: ...
- org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method service() cannot be found on com.my.blog.springboot.thymeleaf.util.MethodTest type
前言 本文中提到的解决方案,源码地址在:springboot-thymeleaf,希望可以帮你解决问题. 至于为什么已经写了一篇文章thymeleaf模板引擎调用java类中的方法,又多此一举的单独整 ...
随机推荐
- 2-1 Numpy-数组
(1) 数组的创建 # !usr/bin/env python # Author:@vilicute import numpy as np # 1.用array创建数组并查看数组的属性 arr1 = ...
- js流星雨效果
css部分 div { border: 0px solid #fff; border-width: 0px 90px 2px 90px; border-color: transparent trans ...
- LintCode_111 爬楼梯
题目 假设你正在爬楼梯,需要n步你才能到达顶部.但每次你只能爬一步或者两步,你能有多少种不同的方法爬到楼顶部? 比如n=3,中不同的方法 返回 3 1 2 3 5 8 13... step[2] = ...
- ajax请求与form表单提交共存的时候status为canceled
chrome浏览器调试,发现,status竟然是canceled状态 网上总论: 1.在URL变更后,会对当前正在执行的ajax进求进行中止操作.中止后该请求的状态码将为canceled 2.在使用到 ...
- int 和bigint差别有多大?
https://bbs.csdn.net/wap/topics/230059600 请问在mysql中int和bigint差别有多大?在什么情况下需要用到bigint? bigint 带符号的范围是- ...
- MySql5.7 配置文件 my.cnf 设置
https://blog.csdn.net/gzt19881123/article/details/52594783 # MySql5.7配置文件my.cnf设置 [client] port = 33 ...
- Centos7环境下搭建Nginx+Lua+Redis进行数据存取
1.安装依赖环境 yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel 2.安装LuaJIT cd /usr/loca ...
- Atcoder Tenka1 Programmer Contest C C - 4/N
http://tenka1-2017.contest.atcoder.jp/tasks/tenka1_2017_c 我怀疑我是不是智障.... 本来一直的想法是能不能构造出答案,把N按奇偶分,偶数好办 ...
- 2017 ACM/ICPC Asia Regional Shenyang Online:number number number hdu 6198【矩阵快速幂】
Problem Description We define a sequence F: ⋅ F0=0,F1=1;⋅ Fn=Fn−1+Fn−2 (n≥2). Give you an integer k, ...
- myeclipse2013在线安装svn
之前安装svn一直不行.弄了好久.还是在线安装方便. 在Help里面点击Install from Site,然后直接图解: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkb ...