-2
我想寫這個無腳本?如何在jsp中使用jstl更改for循環
<tr>
<% for (int column = 0; column < DataSource.getAttributeCount(); column++) { %>
<td><%=row.getAttribute(column)%></td>
<%
}
%>
</tr>
我想寫這個無腳本?如何在jsp中使用jstl更改for循環
<tr>
<% for (int column = 0; column < DataSource.getAttributeCount(); column++) { %>
<td><%=row.getAttribute(column)%></td>
<%
}
%>
</tr>
首先,你應該包括jstl標籤下面JSP頁面:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
之後,你可以使用的forEach標籤迭代查詢列表,以下是可能對您有用的代碼:
<tr>
<c:forEach items="${DataSource.attribute}" varStatus="status">
<td>${row.getAttribute(status.index)}</td>
</c:forEach>
</tr>