struts - Struts 1.3 为表中的特殊属性迭代一次
问题描述
我的 .jsp 文件中有一个 tbody:
<tbody>
<logic:iterate name="tableList" property="list" id="e">
<tr class="text-center">
<td class="text-center"><bean:write name="e" property="A" /></td>
<td class="text-center"><bean:write name="e" property="B" /></td>
<td class="text-center"><bean:write name="e" property="C" /></td>
</tr>
</logic:iterate>
</tbody>
我只想迭代我的属性“A”一次,但“B”和“C”正常迭代。有什么办法吗?
我尝试在 java 类中验证它,当我的 A 属性只有一项时,我使用了行跨度,但是当我想:
<td rowspan="12" class="text-center"><bean:write name="e" property="A" /></td>
它也不能工作(整张桌子都被破坏了)。
解决方案
您可以在 indexId 属性上使用计数器并使用 logic:equal 或 jstl c:if 进行测试,如下所示:
<c:if test="${condition}">
condition is true
</c:if>
代码下方
<tbody>
<logic:iterate name="tableList" property="list" indexId="ctr" id="e">
<tr class="text-center">
<logic:equal name="ctr" value="0" >
<td class="text-center"><bean:write name="e" property="A" /></td>
</logic:equal>
<td class="text-center"><bean:write name="e" property="B" /></td>
<td class="text-center"><bean:write name="e" property="C" /></td>
</tr>
</logic:iterate>
推荐阅读
- angular - 如何完成 Material Stepper Step,并继续下一步?
- cakephp - 如何将数据插入两个不关联的表中 cakephp
- bash - 在没有整个父目录的情况下在当前工作目录中创建 tar?
- nginx - 启用 opcache 的 PHP7.4 预加载 fpm 错误
- java - Java中的编辑距离:如何安排代码?
- css - CSS 网格模板列 - 它是如何工作的?
- java - 不同线程使用的相同变量正在同步块内更新
- angular - 如何获取 ACL 的动态权限
- vb.net - 使用存储过程绑定到 DataGridView
- javascript - 在 twilio 视频中,有没有办法区分远程参与者是故意断开连接还是由于网络错误?