我在arraylist中有 n 元素,我想在(n / 3)X 3格式的表中(通过单次迭代)显示所有那些具有相应数量的单选按钮,例如< / p>
<table>
<tbody>
<tr>
<td><input type="radio" name="category1" id="category1" value="1"></td>
<td><input type="radio" name="category1" id="category1" value="2"></td>
<td><input type="radio" name="category1" id="category1" value="3"></td>
</tr>
<tr>
<td><input type="radio" name="category1" id="category1" value="4"></td>
<td><input type="radio" name="category1" id="category1" value="5"></td>
<td><input type="radio" name="category1" id="category1" value="6"></td>
</tr>
...
<tr>
<td><input type="radio" name="category1" id="category1" value="n"></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
请帮忙
答案 0 :(得分:3)
您可以使用h:panelGrid
和c:forEach
<h:panelGrid columns="3">
<c:forEach items="#{myBean.list}" var="item">
<h:outputText value="#{item}" />
</c:forEach>
</h:panelGrid>
它将呈现<table />
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
...
</tbody>