我的首页的栏目都需要在后台添加,但是添加的栏目又都会在导航栏显示,因此我能不能控制导航栏输出的栏目数呢
比如:
<c:forEach var="nList" items="${iac.listContent}" varStatus="statusNum">
<!-- 控制输出个数 -->
<c:if test="${statusNum.count < 7}">
<li class="els1"> <!-- 控制新闻标题输出长度 只输出10个字 -->
<!-- 如果控制其它的内容 只替换nList.title成其它的即可 -->
<c:set value="${fn:length(nList.title)}" var="length"/>
<c:choose>
<c:when test="${length<10}">
<a href="${basePath }/web/showNewsDetail.do?newsId=${nList.newsId }&curPage=1&itemId=${nList.itemId }&merchantId=${mer.merchantId }&auditStatus=${auditStatus }">${nList.title }</a>
</c:when>
<c:otherwise>
<c:set var="content" value=" ${fn:substring(nList.title,0,10)}..."/>
<a href="${basePath }/web/showNewsDetail.do?newsId=${nList.newsId }&curPage=1&itemId=${nList.itemId }&merchantId=${mer.merchantId }&auditStatus=${auditStatus }">${content }</a>
</c:otherwise>
</c:choose>
<!-- 控制新闻标题输出长度结束 --> </li>
</c:if>
</c:forEach>
求指教 谢谢!!
比如:
<c:forEach var="nList" items="${iac.listContent}" varStatus="statusNum">
<!-- 控制输出个数 -->
<c:if test="${statusNum.count < 7}">
<li class="els1"> <!-- 控制新闻标题输出长度 只输出10个字 -->
<!-- 如果控制其它的内容 只替换nList.title成其它的即可 -->
<c:set value="${fn:length(nList.title)}" var="length"/>
<c:choose>
<c:when test="${length<10}">
<a href="${basePath }/web/showNewsDetail.do?newsId=${nList.newsId }&curPage=1&itemId=${nList.itemId }&merchantId=${mer.merchantId }&auditStatus=${auditStatus }">${nList.title }</a>
</c:when>
<c:otherwise>
<c:set var="content" value=" ${fn:substring(nList.title,0,10)}..."/>
<a href="${basePath }/web/showNewsDetail.do?newsId=${nList.newsId }&curPage=1&itemId=${nList.itemId }&merchantId=${mer.merchantId }&auditStatus=${auditStatus }">${content }</a>
</c:otherwise>
</c:choose>
<!-- 控制新闻标题输出长度结束 --> </li>
</c:if>
</c:forEach>
求指教 谢谢!!
这样应该OK的啊!!!
只是要记住、.count从1开始
.index从0开始!
<li><a href="${basePath }/web/webShowItem.do?ecId=${mer.merchantId }&flag=index">首 页</a></li>
<c:forEach var="nList" items="${iac.listContent}" varStatus="statusNum">
<!-- 控制输出个数 -->
<c:if test="${statusNum.count < 7}">
<li class="els1">
<logic:iterate id="item" name="itemList">
<c:if test="${item.displayFlag == 1}">
<c:if test="${item.encryptFlag == 1 }">
<c:if test="${auditStatus == 1 }">
<!-- <li>-->
<a href="${basePath }/${item.itemType.foreUrl}itemId=${item.itemId }">
<bean:write name="item" property="itemName" /></a>
<!--</li>-->
</c:if>
</c:if>
<c:if test="${item.encryptFlag == 0}">
<!--<li>-->
<a href="${basePath }/${item.itemType.foreUrl}itemId=${item.itemId }&merchantId=${mer.merchantId }&auditStatus=${auditStatus }">
<bean:write name="item" property="itemName" /></a> </c:if>
</c:if>
</logic:iterate>
</li>
</c:if>
</c:forEach> </ul>
这样导航栏总是只显示首页,其他栏目都显示不出来.......
<c:forEach ......>
<c:set var="counts" value="${counts + 1 }"></c:set>
<c:if test="${counts < 7}">
......
</c:if>
</c:forEach>
不用它的count试看看~~~自己声明一个counts变量!
如果还是不行的话、那就可能是你的数据、或者下面的if条件有问题了!!!
这个还不好调试、你把他们(if里面的变量值)全部输出来看看就知道了!