分页的样式就是这样的
cotroller这里这么写,传给view总页数,现在的页数,下一页,上一页的信息
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");
}

 
1
    private String homeInfo(Model model) {
2
        Page<PostEntity> postEntities= postService.findAllByPage(0,10);
3
        model.addAttribute("posts",postEntities.getContent());
4
        int totalPage=postEntities.getTotalPages();
5
        int nowPage=postEntities.getPageable().getPageNumber()+1;
6
        int prePage=nowPage>2?nowPage-1:0;
7
        int nextPage=nowPage<totalPage?nowPage+1:0;
8

9
        model.addAttribute("totalPage",totalPage);
10
        model.addAttribute("nowPage",nowPage);
11
        model.addAttribute("prePage",prePage);
12
        model.addAttribute("nextPage",nextPage);
13
        return render("index");
14
    }

view版这么写
<!--分页-->
<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>
 
1
                <!--分页-->
2
                <div style="text-align: center">
3
                    <a class="pure-button" href="/">首页</a>
4
                    <a class="pure-button" th:if="${prePage != 0}" th:href="@{'/page/'+${prePage}}">上一页</a>
5
                    <a class="pure-button" th:if="${nextPage != 0}" th:href="@{'/page/'+${nextPage}}">下一页</a>
6
                    <a class="pure-button" th:href="@{'/page/'+${totalPage}}">尾页</a>
7
                </div>

springboot+thymeleaf 纯后台渲染偷懒版分页的更多相关文章

  1. springboot thymeleaf ----服务端渲染html

    一. 引用命名空间 <html xmlns:th="http://www.thymeleaf.org"> 不这么写 html标签没闭合会报错 二.实际内容在../sta ...

  2. springboot+thymeleaf+pageHelper带条件分页查询

    html层 <div> <a class="num"><b th:text="'共 '+ ${result.resultMap['pages ...

  3. 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: ") ...

  4. highcharts 结合phantomjs纯后台生成图片系列二之php2

    上篇文章中介绍了phantomjs的使用场景,方法. 本篇文章详细介绍使用php,highcharts 结合phantomjs纯后台生成图片.包含一步步详细的php代码 一.highcharts 结合 ...

  5. highcharts 结合phantomjs纯后台生成图片系列二之php

    上篇文章中介绍了phantomjs的使用场景,方法.本篇文章详细介绍使用php,highcharts 结合phantomjs纯后台生成图片. 一.准备: 下载phantomjs解析插件,从 highc ...

  6. highcharts 结合phantomjs纯后台生成图片

    highcharts 结合phantomjs纯后台生成图片 highcharts 这个图表展示插件我想大家应该都知道,纯javascript编写,相比那些flash图表插件有很大的优势,至少浏览器不用 ...

  7. 原生js版分页插件

    之前我在自己的博客里发表了一篇用angularJs自定义指令实现的分页插件,今天简单改造了一下,改成了原生JavaScript版本的分页插件,可以自定义一些简单配置,特此记录下来.如有不足之处,欢迎指 ...

  8. 一款基于SpringBoot+SpringSecurity的后台管理系统,强烈推荐

    简介 Base Admin一套简单通用的后台管理系统,主要功能有:权限管理.菜单管理.用户管理,系统设置.实时日志,API加密,以及登录用户修改密码.配置个性菜单等. 技术栈 前端:Layui 后端: ...

  9. 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类中的方法,又多此一举的单独整 ...

随机推荐

  1. Python操作SQLite数据库的方法详解

    Python操作SQLite数据库的方法详解 本文实例讲述了Python操作SQLite数据库的方法.分享给大家供大家参考,具体如下: SQLite简单介绍 SQLite数据库是一款非常小巧的嵌入式开 ...

  2. org.apache.jasper.JasperException: xxxx.jsp(118,24) Attribute style invalid for tag formatNumber according to TLD

    错误:org.apache.jasper.JasperException: /projm/projBudgetChangeOverview.jsp(118,24) Attribute style in ...

  3. MVVMDemo

    QueryCommand.cs using System;using System.Collections.Generic;using System.Linq;using System.Text;us ...

  4. 深入浅出Javascript闭包

    一.引子 闭包(closure)是 Javascript 语言的一个难点,面试时常被问及,也是它的特色,很多高级应用都要依靠闭包实现.本文尽可能用简单易懂的话,讲清楚闭包的概念.形成条件及其常见的面试 ...

  5. Python 使用正则表达式抽取数据

  6. sas信用评分之第二步变量筛选

    sas信用评分之第二步变量筛选 今天介绍变量初步选择.这部分的内容我就只介绍information –value,我这次做的模型用的逻辑回归,后面会更新以基尼系数或者信息熵基础的筛选变量,期待我把. ...

  7. JMeter与LoadRunner的对比

    1. 界面.安装.协议支持.函数库.成本.开源 2. 都可以实现分布式负载,相对来说LoadRunner更强大一些 3. 都支持在windows和linux环境的负载生成器.控制台方面,Jmeter跨 ...

  8. 洛谷 P1027 Car的旅行路线 最短路+Dijkstra算法

    目录 题面 题目链接 题目描述 输入输出格式 输入格式 输出格式 输入输出样例 输入样例 输出样例 说明 思路 AC代码 总结 题面 题目链接 P1027 Car的旅行路线 题目描述 又到暑假了,住在 ...

  9. JavaScript学习之 倒计时

    倒计时很常见,例如离XX活动还有XX天XX小时XX分XX秒,然后逐秒减少,实现很简单,我只是想记录这过程中的一点小坑. 先上代码: <html> <head> <meta ...

  10. springboot 启动配置原理【转】【补】

    创建应用 几个重要的事件回调机制  , 配置在META-INF/spring.factories ApplicationContextInitializer SpringApplicationRunL ...