>我在数组列表中有 n 个元素,我想在 (n/3) X 3 格式的表格中显示所有这些元素(通过单次迭代),并带有相应数量的单选按钮,例如,
<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>
请帮忙
你可以
只使用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>