2012-04-16 16 views
0

私はこのサイトの前の例を見直しましたが、何もできませんでした。私はまた、私のジレンマを見つけましたが、成功はありませんでした。JSTLの最終コンマを省略<c:out>

私はここでいくつかのコードをデバッグしようとしています。私は最後のカンマを削除するように見えるかもしれません。思考?

<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> 
+0

ここで何をしようとしていますか?入力?出力?どのような例を読んでいますか? – evanwong

+0

最後の部署の後にカンマが表示されています – rlegs

答えて

0

使用varStatus

<c:if test="${not deptsCounter.last}"> 
</c:if> 
+0

ありがとうございます。私はこれを試して、それが動作していない。 – rlegs

+0

あなたは作業していないと精緻化できますか? –

+0

最後の部署の後にコンマが残っています – rlegs

1

あなたはすべてのvarStatusプロパティのリストは、ここでこのよう

<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> 

で最後の項目にある場合は、テストすることができ、最終的なカンマを省略します

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 
関連する問題