zoukankan      html  css  js  c++  java
  • Java 学习笔记(三)

    在页面上只显示最多5个页码:

    主要思路其实就是分情况:

    1. 总页数小于5页时

    2. 总页数大于5页时,且当前页距离首页距离小于2

    3. 总页数大于5页时,且当前页距离末页距离小于2
    4. 总页数大于5页时,且当前页距离首页距离和末页距离都大于2

            <ul class="pagination">
                <li th:class="${pageinfo.isHasPreviousPage()}?'' : 'disabled'">
                    <a th:href="@{'/all?pageNum=' + ${pageinfo.getPageNum()-1}}">上一页
                    </a>
                </li>
                <li th:if="${pageinfo.getPages()<= 5}" th:each="i :${pageinfo.getNavigatepageNums()}"
                    th:class="${pageinfo.getPageNum() == i}? 'page-item active' :' ' ">
                    <a th:href="@{'/all?pageNum=' + ${i}}" th:text="  ${i}"></a>
                </li>
    
                <li th:if="${pageinfo.getPages()> 5 && (pageinfo.getPages() - pageinfo.getPageNum()) <= 2}"
                    th:each="i :${#numbers.sequence(pageinfo.getPages() - 4, pageinfo.getPages())}"
                    th:class="${pageinfo.getPageNum() == i}? 'page-item active' :' ' ">
                    <a th:href="@{'/all?pageNum=' + ${i}}" th:text="  ${i}"></a>
                </li>
    
                <li th:if="${pageinfo.getPages()> 5 && (pageinfo.getPageNum() - 1) <= 2}"
                    th:each="i :${#numbers.sequence(1, 5)}"
                    th:class="${pageinfo.getPageNum() == i}? 'page-item active' :' ' ">
                    <a  th:href="@{'/all?pageNum=' + ${i}}" th:text="  ${i}"></a>
                </li>
    
                <li th:if="${pageinfo.getPages()> 5 && ((pageinfo.getPageNum() - 1) > 2)&& (pageinfo.getPages() - pageinfo.getPageNum()) > 2}"
                    th:each="i :${#numbers.sequence(pageinfo.getPageNum() - 2, pageinfo.getPageNum() + 2)}"
                    th:class="${pageinfo.getPageNum() == i}? 'page-item active' :' ' ">
                    <a th:href="@{'/all?pageNum=' + ${i}}" th:text="  ${i}"></a>
                </li>
    
                <li th:class="${pageinfo.isHasNextPage()}?'' : 'disabled'">
                    <a th:href="@{'/all?pageNum=' + ${pageinfo.getPageNum()+1}}">下一页</a>
                </li>
            </ul>

    从Spring3.0,@Configuration用于定义配置类,可替换xml配置文件.  https://www.cnblogs.com/duanxz/p/7493276.html

  • 相关阅读:
    TriSun PDF to X v11.0 Build 061
    资源管理器 Q-Dir v8.09
    USB启动盘创建工具 Rufus
    Docker:网络模式详解
    rsync使用实践
    MySQL 8.0 防止暴力破解
    MySQL-8.0.19 优化日志及压测
    MySQL入门篇之mysqldump参数说明
    rest-framework之视图
    rest-framework之权限组件
  • 原文地址:https://www.cnblogs.com/crazyghostvon/p/Javalearn3.html
Copyright © 2011-2022 走看看