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

  • 相关阅读:
    HBase写请求分析
    jquery+easyui主界面布局一例
    调试LD_PRELOAD注入的代码
    获取Oracle隐含參数信息
    Android组件系列----ContentProvider内容提供者【4】
    053第401题
    高速排序优化通过中位数优化
    较难理解的概念
    HDU 2546 饭卡(dp)
    HDU 2546 饭卡(dp)
  • 原文地址:https://www.cnblogs.com/crazyghostvon/p/Javalearn3.html
Copyright © 2011-2022 走看看