开发者

Vector in JSP page

How I can iterate a vector in a JSP page?

I have done it:

<%
 Vector value = (Vector) request.getAttribute("status");
 for (Enumeration e = value.elements(); e.hasMoreElements(); )
 {
        StatusItem myStatus = (StatusItem) e.nextElement();

 }
%>开发者_高级运维; 

Is there any way to do it with jsp tags? Thx


Print out the contents of the vector like this:

<c:foreach var="myStatus" items="${status}" >
  <!-- print out the value of each status in the vector.
       Method getValue() must exist in the status class.-->
  <c:out value="${myStatus.value}"/>
</c:foreach>


You can iterate collections by <c:forEach> jstl tag:

<c:forEach var="s" items="${status}">
    item is: ${s}
</c:forEach>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜