I have an ordered list of names, and I need to make the third item on the list bold. Only the third item should be bold. After that it should return to regular font. Here's what I have as of now:
<ol>
&开发者_C百科lt;c:forEach items="${names}" var="entry" varStatus="status">
<li>
${entry}
<c:if test="${entry eq 'Jeff'}"> is a grader.</c:if>
<c:if test="${entry eq 'jeff'}"> is a grader.</c:if>
</li>
</c:forEach>
</ol>
Would I still be using <b>
tags, or is there another way to bold certain text (using JSTL)?
Make use of the varStatus="status"
you got there. It refers to a local LoopTagStatus
instance which offers you among others the (self-explaining) getIndex()
method.
<c:if test="${status.index == 2}"><b>This is the 3rd item.</b></c:if>
(yes, also here, array indexes start at 0)
精彩评论