zoukankan      html  css  js  c++  java
  • springboot+thymeleaf 纯后台渲染偷懒版分页

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




  • 相关阅读:
    【JVM基础】JVM垃圾回收机制算法
    【java基础】- java双亲委派机制
    Java基础(一)
    JVM
    冷知识: 不会出现OutOfMemoryError的内存区域
    疯狂Java:突破程序员基本功的16课-李刚编著 学习笔记(未完待续)
    nor flash之写保护
    spinor/spinand flash之高频通信延迟采样
    nor flash之频率限制
    使用littlefs-fuse在PC端调试littlefs文件系统
  • 原文地址:https://www.cnblogs.com/tilv37/p/9365430.html
Copyright © 2011-2022 走看看