分页的样式就是这样的
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. ELK学习目录

    DAY1.elasticsearch和kibana环境搭建以及简单介绍 A:环境搭建配置 (1)java虚拟机安装:https://www.cnblogs.com/studybrother/p/108 ...

  2. Serializable 可串行化接口

    Serializable 可串行化接口 定义一个User类,实现Serializable接口: package com.monkey1025; import java.io.Serializable; ...

  3. 使用mpvue开发github小程序总结

    前言 最近有点闲,想起关注已久的mpvue写小程序,所以稍微肝了半个多月写了个github版的微信小程序,已上线.现在总结一下遇到的坑. 扫码体验. 项目地址.https://github.com/c ...

  4. 一.数据结构&算法的引言+时间复杂度

    目录(contents): 1.什么是计算机科学?什么是算法? 2.如何形象化的理解算法? 3.什么是算法分析? 4.时间复杂度 5.数据结构 6.总结算法和数据结构之间的关联 一.什么是计算机科学? ...

  5. 【7.19 graphshortestpath graphallshortestpaths函数】matlab 求最短路径函数总结

    graphshortestpath 函数是用来解决最短路径问题的. 语法为: [dist, path, pred]=graphshortestpath(G,S) [dist, path, pred]= ...

  6. spring boot + mybatis 访问 neo4j

    之前有通过rest的风格去访问,但是每次需要访问时候将statement一并加入header中去数据库执行,方式简单.且思路清晰,但是不便于形成模板调用,固采用mybaits来集成. 1.关键pom. ...

  7. Python2.7下,调用subprocess启动子进程,读取子进程标准输出若干问题

    1:如果调用的子进程也是一个python脚本,则subprocess.Popen中的bufsize=1无效果.也就是说,即使设置了bufsize=1表示进行行缓冲,子进程如果不显示调用sys.stdo ...

  8. 洛谷1602 Sramoc问题

      刚看到这道题的时候感觉像spfa. 然后发现其实bfs就可以做了. //Serene #include<algorithm> #include<iostream> #inc ...

  9. mysqldump导出表结构或者表数据

    加-d参数代表只导表结构,不加此参数则代表导出结构以及表数据,> 代表录入某一文件,若为>>则表示将内容追加到某文件末尾. -- 导出数据库为dbname的表结构 mysqldump ...

  10. linux 系统下如何进行用户之间的切换

    切换用户的命令是su,su是(switch user)切换用户的缩写.通过su命令,可以从普通用户切换到root用户,也可以从root用户切换到普通用户.从普通用户切换到root用户需要密码(该密码是 ...