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类中的方法,又多此一举的单独整 ...
随机推荐
- This Product is covered by one or more of the folloWing patents
借用一下网络图片,作为描述: 原因: 启动方式使用了网络启动, 解决方案: 进入bios,修改启动方式,禁用网卡驱动,使用从硬盘启动或者从U盘启动即可.
- ThinkPHP中_after_update、_before_update等的用法
https://blog.csdn.net/aslackers/article/details/50339163 TP系统\Think\Model类里隐藏了几个有用的方法: _before_inser ...
- Nginx教程(6) 动静分离架构 (转)
一.原理 Nginx 动静分离简单来说就是把动态跟静态请求分开,不能理解成只是单纯的把动态页面和静态页面物理分离.严格意义上说应该是动态请求跟静态请求分开,可以理解成使用Nginx 处理静态页面,To ...
- ipad模拟器iPadian.exe
http://dl.pconline.com.cn/download/368140.html 苹果IPAD模拟器!让你的电脑立刻拥有IOS系统!马上变成ipad!几百个免费的扩展应用程序,能登QQ,微 ...
- python系列之(2)PyQuery的用法
1.了解 pyquery库是jQuery的Python实现,能够以jQuery的语法来操作解析 HTML 文档,易用性和解析速度都很好. 2.安装 pip install pyquery 3引用 ...
- 关于element-ui的弹框问题
el-dialog获取数据. el-dialog加载到页面中的时候,其实已经加载好了.只是默认隐藏了. 第一次点击的时候弹出,为何拿不到数据?之后再次操作就一点问题都没有了.
- docker search
命令:docker search [root@iZ943kh74qgZ ~]# docker search --help Usage: docker search [OPTIONS] TERM Sea ...
- 小爬爬5:scrapy介绍3持久化存储
一.两种持久化存储的方式 1.基于终端指令的吃持久化存储: 特点:终端指令的持久化存储,只可以将parse方法的返回值存储到磁盘文件 因此我们需要将上一篇文章中的author和content作为返回值 ...
- 洛谷 P3768 简单的数学题 (莫比乌斯反演)
题意:求$(\sum_{i=1}^{n}\sum_{j=1}^{n}ijgcd(i,j))mod p$(p为质数,n<=1e10) 很显然,推式子. $\sum_{i=1}^{n}\sum_{j ...
- Spring中配置DataSource数据源的几种选择
从JNDI获得DataSource. 从第三方的连接池获得DataSource. 使用DriverManagerDataSource获得DataSource. 一.从JNDI获得DataSource ...