freemarker 分页逻辑
生活随笔
收集整理的這篇文章主要介紹了
freemarker 分页逻辑
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<#--?分頁(yè)組件需要傳入的參數(shù) pageUrl ,用來生成的html地址,在pageUrl中必須有{page}在生成html地址的時(shí)候會(huì)自動(dòng)把頁(yè)碼給賦值上去。頁(yè)碼起始值為1@pageNum 最大顯示頁(yè) 默認(rèn)9@beforPage 前顯示頁(yè) 默認(rèn)3@afterPage ?后顯示頁(yè) 默認(rèn)3@countPage 總頁(yè)數(shù) ? 必須傳入@currentPage 當(dāng)前頁(yè) 必須傳入@currentPageClass 選中頁(yè)碼傳遞的樣式,實(shí)現(xiàn)為直接將值貼給元素 <a href="#" ${currentPageClass}>@pageUrl ?請(qǐng)求地址模板 ,內(nèi)容中必須含有{page}用來替換頁(yè)碼-->
<#assign pageNum = pageNum!9>
<#assign beforPage = beforPage!3>
<#assign afterPage = afterPage!3>
<#assign countPage =countPage!page.countPageNumber>
<#assign currentPage = currentPage!page.currentNumber>
<#assign currentPageClass = currentPageClass!"class='thispage'">
<#assign pageUrl = pageUrl>
<#-- 分頁(yè)地址 -->
<#function getPageUrl page><#return pageUrl?replace('{page}',page)>
</#function><#if (countPage > 1)><#if currentPage != 1><a class="nextpage m_l15" href="${getPageUrl(currentPage - 1)}">上一頁(yè)</a></#if><#if (countPage > pageNum)><#-- 總頁(yè)數(shù)大于最大顯示頁(yè) --><#if (pageNum > currentPage)><#-- 當(dāng)前頁(yè)小于顯示頁(yè) --><#list 1..pageNum as index><a href="${getPageUrl(index)}" ?<#if currentPage == index>${currentPageClass}</#if>>${index}</a></#list><#else><a href="${getPageUrl(1)}">1</a>...<#list currentPage-beforPage..currentPage + afterPage as index><#if (index > 0) && (index < countPage)><a href="${getPageUrl(index)}" ?<#if currentPage == index>${currentPageClass}</#if>>${index}</a></#if></#list></#if>?<#if (currentPage < countPage - afterPage)>...</#if><a href="${getPageUrl(countPage)}" <#if currentPage == countPage>${currentPageClass}</#if>>${countPage}</a><#else><#-- 總頁(yè)數(shù)小于顯示頁(yè) --><#list 1..countPage as index><a href="${getPageUrl(index)}" ?<#if currentPage == index>${currentPageClass}</#if>>${index}</a></#list></#if><#if countPage != currentPage><a class="nextpage" href="${getPageUrl(currentPage + 1)}">下一頁(yè)</a></#if>
</#if>
轉(zhuǎn)載于:https://my.oschina.net/wjgood/blog/97489
總結(jié)
以上是生活随笔為你收集整理的freemarker 分页逻辑的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 做梦梦到猫和狗是什么征兆
- 下一篇: Anonymous Inner Clas