【问题标题】:How can I get input side by side in JSP如何在 JSP 中并排获取输入
【发布时间】:2011-08-16 14:32:14
【问题描述】:
<table>
<c:forEach items="${requestScope['rfpq.mailRecievers']}" var="row">
<tr>
                                            <td>&nbsp; </td>
<td style="color: #000000; font-size: 11px;" height="17" width="450">  &nbsp;${row} |</td> 

</tr>
</c:forEach>
</table>

输入是:

A0001 |

A0002 |

A0003 |

A0004 |

A0005 |

我将如何获得输入(带有颜色):

A0001 | (颜色:灰色) A0002 | A0003 | (颜色:灰色)A0004

【问题讨论】:

    标签: html jsp jstl


    【解决方案1】:
    <table>
        <tr>
            <c:forEach items="${requestScope['rfpq.mailRecievers']}" var="row" varStatus="status"  >
                <c:choose>
                    <c:when test="${status.count%2==0}">
                        <td style="color: #000000; font-size: 11px;" height="17">   &nbsp;${row} |</td> 
                    </c:when>
                    <c:otherwise>
                        <td style="color: gray; font-size: 11px;" height="17">   &nbsp;${row}|</td> 
                     </c:otherwise>
                 </c:choose>
            </c:forEach>
        </tr>
    </table>
    

    您可以使用varStatus 属性访问当前&lt;c:forEach&gt;LoopTagStatus 实例,它的count 属性为您提供循环计数器。您可以使用此循环计数器来设置奇数列和偶数列的样式。

    【讨论】:

    • 我已经试过了,但是当我写这个的时候我的桌子爆炸了。
    • 另外我写道: 也有同样的问题,桌子炸弹。
    • 你好像也想设置奇数列和偶数列的样式,刚刚更新了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-24
    • 1970-01-01
    • 1970-01-01
    • 2020-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多