freemarker、分页,自定义过的一个分页
程序员文章站
2022-07-12 19:27:26
...
用freemarker做过的一个自定义标签,分页用的 <#macro page totalPage total actionUrl pageSize currentPage > <#if (total>0)> <#if actionUrl?contains("?")> <#assign actionUrl="${actionUrl }&pageSize=${pageSize }&pageNumber="> <#else> <#assign actionUrl="${actionUrl }?&pageSize=${pageSize }&pageNumber="> </#if> <ul id="myPage" class="pagination pagination-small m-t-none m-b-none"> <#-- 上一页按钮 --> <#if (currentPage > 1) > <li><a href="${actionUrl }${currentPage -1 }" > <@spring.message "tags.myPage2.PreviousPage" /> </a></li> </#if> <#-- 第一页按钮 --> <#if 1 == currentPage> <li class="active"><a>1</a></li> <#else> <li><a href="${actionUrl}1" ></a></li> </#if> <#if (totalPage<7)> <#if ((totalPage - 1)>=2)> <#list 2..(totalPage - 1) as i> <#if currentPage == i> <li class="active"><a>${i }</a></li> <#else> <li><a href="${actionUrl }${i }" >${i }</a></li> </#if> </#list> </#if> <#else> <#if (currentPage < 6)> <#list 2..5 as i> <#if currentPage == i > <li class="active"><a>${i }</a></li> <#else> <li><a href="${actionUrl }${i }" >${i }</a></li> </#if> </#list> <#if ((currentPage + 2) <= totalPage)> <li><a>...</a></li> </#if> <#else> <#if ((totalPage - currentPage) < 5)> <#if ((totalPage - 4) > 2)> <li><a>...</a></li> </#if> <#list (totalPage -4)..(totalPage -1) as i> <#if currentPage == i > <li class="active"><a>${i }</a></li> <#else> <li><a href="${actionUrl }${i }" >${i }</a></li> </#if> </#list> <#else> <li><a>...</a></li> <#list (currentPage -2)..(currentPage +2) as i> <#if currentPage == i> <li class="active"><a>${i }</a></li> <#else> <li><a href="${actionUrl }${i }" >${i }</a></li> </#if> </#list> <li><a>...</a></li> </#if> </#if> </#if> <#-- 最后一页按钮 --> <#if (totalPage > 1)> <#if totalPage == currentPage > <li class="active"><a>${totalPage }</a></li> <#else> <li><a href="${actionUrl }${totalPage }" >${totalPage }</a></li> </#if> </#if> <#-- 下一页按钮 --> <#if (totalPage > currentPage)> <li><a href="${actionUrl }${currentPage +1}" > <@spring.message "tags.myPage2.NextPage" /> </a></li> </#if> </ul> </#if> <#if (total <= 0)> <@spring.message "decorator.common.search_empty" /> </#if> </#macro> <@page totalPage='${pageCount}'?number total='${pageInfo.totalCount}'?number actionUrl="${ctx}/detail/detail/${dto.productId?c}" pageSize='${pageInfo.pageSize}'?number currentPage='${pageInfo.pageNum}'?number /> <#-- pageCount 页数,total 总条数 ,pageSize 每页数量,currentPage 当前页 -->
上一篇: spirng 后台传到前台json 乱码