search

Home  >  Q&A  >  body text

java - struts2的jsp页面的table每行显示四个td应该怎么写代码?

我在某table里用<s:iterator>显示某List的内容,想每行显示四个td,写了如下代码:

<s:if test="!(#st.index % 4)"><tr></s:if>
某些td代码
<s:if test="!(#st.index % 4)"></tr></s:if>

结果显示错乱,有的行显示一个td,有的显示3个。怎么才能按照我的想法显示?

PHPzPHPz2893 days ago409

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:18:58

    Isn’t this okay?

    <s:iterator value="#list" id="obj">
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </s:iterator>

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:18:58

    <s:iterator>
            <s:if test="(#st.index % 4) == 0 && (#st.index != 0)">
                </tr>
                <tr>
            </s:if>
            <s:elseif test="#st.index == 0">
                <tr>
            </s:elseif>
    </s:iterator>

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:18:58

    The problem is solved, you should put:

    between the <s:iterator> and </s:iterator> tags
            <s:if test="(#st.index % 4) == 0 && (#st.index != 0)">
                </tr>
                <tr>
            </s:if>
            <s:elseif test="#st.index == 0">
                <tr>
            </s:elseif>

    reply
    0
  • Cancelreply