【问题标题】:Struts2 table creationStruts2 表创建
【发布时间】:2014-09-10 08:55:20
【问题描述】:

我已经尝试过一段时间了,但我得到了两列,相邻列具有相同的数据。

<table bgcolor="white" bordercolor="green" border="1" cellspacing="0" cellpadding="1" align="center">
        <tr bgcolor="green">
            <th>Login Name</th>
            <th>Full Name</th>
        </tr>
        <s:iterator value="%{#session.users}" status="usrsts">

                <s:if test="#usrsts.odd==true">
                <tr>
                    <td style="background: gray;"><s:a ><s:property/></s:a></td>
                    </tr>
                </s:if>
                <s:else>
                    <td style="background: white;"><s:property /></td>
                </s:else>

        </s:iterator>
</table>

问题是我无法将其作为两列表打印为单列表本身。

【问题讨论】:

    标签: jsp html-table struts2 iterator


    【解决方案1】:

    也许应该这样做:

    <table bgcolor="white" bordercolor="green" border="1" 
           cellspacing="0" cellpadding="1" align="center">
        <tr bgcolor="green">
            <th>Login Name</th>
            <th>Full Name</th>
        </tr>
        <s:iterator value="%{#session.users}" status="usrsts">
           <s:if test="#usrsts.odd==true">
                <tr style="background: gray;">
           </s:if>
           <s:else>
                <tr style="background: white;">
           </s:else>
                    <td ><s:a><s:property value="username"/></s:a></td>
                    <td ><s:property value="fullname"/></td>
               </tr>
        </s:iterator>
    </table>
    

    【讨论】:

    • 我认为问题与迭代器有关,每次它为打印数据创建新行时..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-08
    相关资源
    最近更新 更多