当前位置: 动力学知识库 > 问答 > 编程问答 >

jsp - Struts2 table creation

问题描述:

Yah I have tried this a while before. But I got 2 columns with adjacent columns having identical data.

<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>

the problem is i couldn't make it as a 2 column table it prints as single column table itself.

网友答案:

Maybe something like this should do it:

<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>
分享给朋友:
您可能感兴趣的文章:
随机阅读: