Java 省略JSTL中的最后一个逗号<;c:out>;
我在这个网站上回顾了以前的例子,但什么都做不到。我也用谷歌搜索了我的困境,但没有成功 我正在调试一些代码。我似乎去掉了最后一个逗号。想法Java 省略JSTL中的最后一个逗号<;c:out>;,java,jsp,jstl,Java,Jsp,Jstl,我在这个网站上回顾了以前的例子,但什么都做不到。我也用谷歌搜索了我的困境,但没有成功 我正在调试一些代码。我似乎去掉了最后一个逗号。想法 <c:forEach items="${userDeptList}" var="userDeptVar" varStatus="userDeptCounter" > <c:if test="${contactsVar.userId==userDeptVar.userID}"> <c:forEach items="
<c:forEach items="${userDeptList}" var="userDeptVar" varStatus="userDeptCounter" >
<c:if test="${contactsVar.userId==userDeptVar.userID}">
<c:forEach items="${deptPtypeList}" var="deptsVar" varStatus="deptsCounter" >
<c:if test="${deptsVar.ptypeID==userDeptVar.deptID}">
<c:out value="${deptsVar.type}" escapeXml="false"></c:out>
<c:out value="," escapeXml="false"></c:out>
</c:if>
</c:forEach>
</c:if>
</c:forEach>
使用
varStatus
<c:if test="${not deptsCounter.last}">
</c:if>
要省略最后一个逗号,您可以通过这种方式测试您是否在最后一项上
<c:forEach items="${userDeptList}" var="userDeptVar" varStatus="userDeptCounter" >
<c:if test="${contactsVar.userId==userDeptVar.userID}">
<c:forEach items="${deptPtypeList}" var="deptsVar" varStatus="deptsCounter" >
<c:if test="${deptsVar.ptypeID==userDeptVar.deptID}">
<c:out value="${deptsVar.type}" escapeXml="false"></c:out>
<c:if test="${not userDeptCounter.last}>
<c:out value="," escapeXml="false"></c:out>
</c:if>
</c:if>
</c:forEach>
</c:if>
</c:forEach>
你想在这里干什么?输入?输出?你读了什么例子?我在最后一个部门后仍然得到一个逗号我在最后一个部门更新后仍然得到一个逗号,最内部循环的varstatus需要考虑我不知所措…这应该行得通我在发布之前尝试过。我不明白。
current The item (from the collection) for the current round of iteration
index The zero-based index for the current round of iteration
count The one-based count for the current round of iteration
first Flag indicating whether the current round is the first pass through the iteration
last Flag indicating whether the current round is the last pass through the iteration
begin The value of the begin attribute
end The value of the end attribute
step The value of the step attribute