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个。怎么才能按照我的想法显示?


慕容森
浏览 532回答 3
3回答

MMMHUHU

问题解决了,应该在<s:iterator>和</s:iterator>标签之间放入:&nbsp; &nbsp; &nbsp; &nbsp; <s:if test="(#st.index % 4) == 0 && (#st.index != 0)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </tr>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; </s:if>&nbsp; &nbsp; &nbsp; &nbsp; <s:elseif test="#st.index == 0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; </s:elseif>

HUX布斯

这样不行吗<s:iterator value="#list" id="obj">&nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; <td></td>&nbsp; &nbsp; &nbsp; &nbsp; <td></td>&nbsp; &nbsp; &nbsp; &nbsp; <td></td>&nbsp; &nbsp; &nbsp; &nbsp; <td></td>&nbsp; &nbsp; </tr></s:iterator>

繁华开满天机

<s:iterator>&nbsp; &nbsp; &nbsp; &nbsp; <s:if test="(#st.index % 4) == 0 && (#st.index != 0)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </tr>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; </s:if>&nbsp; &nbsp; &nbsp; &nbsp; <s:elseif test="#st.index == 0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; </s:elseif></s:iterator>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java