分页的样式就是这样的
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. Latex 出现编辑公式,出现错误 !pdfTex error: Font rntxmi7 at 438 not found

    http://docs.miktex.org/manual/advanced.html http://www.cl-projects.de/projects/misc/miktex-fonts.pht ...

  2. asp.net技术(公共方法)

    #region 获取 本周.本月.本季度.本年 的开始时间或结束时间 /// <summary> /// 获取开始时间 /// </summary> /// <param ...

  3. oracle-Dbca数据库模板

    数据库模板是用xml文件格式保存在本地磁盘上的数据库配置的定义. Dbca能够使用两种类型的模板:种子模板和非种子模板. 种子模板指含有定义信息和实际的数据文件与重做日志文件的模板定义. 种子模板的优 ...

  4. Mac上代码开启dump的core文件生成方案

    #ifdef Q_OS_MAC struct rlimit rl; getrlimit(RLIMIT_NOFILE,&rl); rl.rlim_cur = qMin((rlim_t)OPEN_ ...

  5. Linux与Unix shell编程指南(完整高清版).pdf

    找到一本很详细的Linux Shell脚本教程,其实里面不光讲了Shell脚本编程,还介绍了系统的各种命令 http://vdisk.weibo.com/s/yVBlEojGMQMpv 本书共分五部分 ...

  6. 【转载】【python】python练手项目

    入门篇 1.Python - Python 图片转字符画 50 行 Python 代码完成图片转字符画小工具. &lt;img src="https://pic3.zhimg.com ...

  7. linux中的用户、群组和权限

     linux中的用户.群组和权限   新建用户natasha,uid为1000,gid为555,备注信息为“master”   groupadd -g 555 natasha useradd -u 1 ...

  8. c++之手写strcmp

    int strcmp(const char* str1, const char*str2){ assert(str1 != NULL&&str2 != NULL); while (*s ...

  9. Oracle函数——MINUS

    解释 “minus”直接翻译为中文是“减”的意思,在Oracle中也是用来做减法操作的,只不过它不是传统意义上对数字的减法,而是对查询结果集的减法.A minus B就意味着将结果集A去除结果集B中所 ...

  10. ANSI编码方式转化为UTF-8方式

    说明: 记事本txt有四种编码方式,分别为:UTF-8.ANSI.Unicode和Unicode big endian,当进行写操作,创建的txt编码格式,与写入汉字的编码方式相同:如果写入的汉字是不 ...