freemarker、分页,自定义过的一个分页

阅读更多
用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 (currentPage > 1) >
  • <@spring.message "tags.myPage2.PreviousPage" />
  • <#-- 第一页按钮 --> <#if 1 == currentPage>
  • 1
  • <#else>
  • <#if (totalPage<7)> <#if ((totalPage - 1)>=2)> <#list 2..(totalPage - 1) as i> <#if currentPage == i>
  • ${i }
  • <#else>
  • ${i }
  • <#else> <#if (currentPage < 6)> <#list 2..5 as i> <#if currentPage == i >
  • ${i }
  • <#else>
  • ${i }
  • <#if ((currentPage + 2) <= totalPage)>
  • ...
  • <#else> <#if ((totalPage - currentPage) < 5)> <#if ((totalPage - 4) > 2)>
  • ...
  • <#list (totalPage -4)..(totalPage -1) as i> <#if currentPage == i >
  • ${i }
  • <#else>
  • ${i }
  • <#else>
  • ...
  • <#list (currentPage -2)..(currentPage +2) as i> <#if currentPage == i>
  • ${i }
  • <#else>
  • ${i }
  • ...
  • <#-- 最后一页按钮 --> <#if (totalPage > 1)> <#if totalPage == currentPage >
  • ${totalPage }
  • <#else>
  • ${totalPage }
  • <#-- 下一页按钮 --> <#if (totalPage > currentPage)>
  • <@spring.message "tags.myPage2.NextPage" />
<#if (total <= 0)> <@spring.message "decorator.common.search_empty" /> <@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 当前页 -->

 

你可能感兴趣的:(freemarker、分页,自定义过的一个分页)