OpenCms 带分页的新闻列表

花开花谢,人来又走,夕阳西下,人去楼空,早已物是人非矣。也许,这就是结局,可我不曾想过结局是这样;也许,这就是人生的意义,可我不曾想竟是生离死别。
<%@pagesession="false"import="java.text.SimpleDateFormat,java.util.Date"%>
<%@taglibprefix="c"uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglibprefix="fmt"uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglibprefix="cms"uri="http://www.opencms.org/taglib/cms"%>
<html>
<head>
<title>测试新闻列表页</title>
<cms:editable/>
</head> <body>
<!--param="/test/news_%(number).html|testnews"中的/test/是指定要显示信息所在的路径,根据实际情况修改,testnews是指定要显示信息的类型-->
<cms:contentloadcollector="allInFolderPriorityDateDesc"param="/test/news_%(number).html|testnews"preload="true">
<!--pageSize即是每页要显示信息的数量-->
<cms:contentloadpageSize="3"pageIndex="%(param.pageIndex)"pageNavLength="10"editable="true">
<cms:contentinfovar="contentInfo"scope="request"/> <arel="nofollow noopener noreferrer" href="<cms:link><cms:contentshowelement="%(opencms.filename)"/></cms:link>"target="_blank"><cms:contentshowelement="Title"/></a>
<c:setvar="strDate"><cms:contentshowelement="Date"/></c:set>
<%
longlongDate=Long.valueOf(pageContext.getAttribute("strDate").toString()).longValue();
SimpleDateFormatsdf=newSimpleDateFormat("yyyy-MM-ddHH:mm");
StringcreatedDate=sdf.format(newDate(longDate));
out.print(createdDate);
%> </cms:contentload>
<!--以下是分页开始-->
<c:iftest="${contentInfo.pageIndex>1}">
<arel="nofollow noopener noreferrer" href="<cms:link>${cms:getCmsObject(pageContext).requestContext.uri}</cms:link><c:outvalue="?pageIndex=${contentInfo.pageIndex-1}"/>">上一页</a>
</c:if>
<c:forEachvar="i"begin="${contentInfo.pageNavStartIndex}"end="${contentInfo.pageNavEndIndex}">
<c:choose>
<c:whentest="${contentInfo.pageIndex==i}">
<fontcolor="red"><c:outvalue="${i}"/></font>
</c:when>
<c:otherwise>
<arel="nofollow noopener noreferrer" href="<cms:link>${cms:getCmsObject(pageContext).requestContext.uri}</cms:link><c:outvalue="?pageIndex=${i}"/>"><c:outvalue="${i}"/></a>
</c:otherwise>
</c:choose>
</c:forEach>
<c:iftest="${contentInfo.pageIndex<contentInfo.pageCount}">
<arel="nofollow noopener noreferrer" href="<cms:link>${cms:getCmsObject(pageContext).requestContext.uri}</cms:link><c:outvalue="?pageIndex=${contentInfo.pageIndex+1}"/>">下一页</a>
</c:if>
</cms:contentload> </body>
</html>

本文OpenCms 带分页的新闻列表到此结束。我们人这一辈子不是别人的楷模,就是别人的借鉴。小编再次感谢大家对我们的支持!

您可能有感兴趣的文章
ASP.NET中Response.BufferOutput属性的使用技巧

ASP.NET轻量级MVC框架Nancy的基本用法

使用grpcui测试ASP.NET core的gRPC服务

ASP.NET Core中的对象池介绍

.NET集成ORM框架HiSql