带有迭代器的struts2表显示不同行中的复选框

时间:2011-08-03 21:50:33

标签: checkbox struts2 html-table iterator

我在jsp中有以下代码。

<table>
    <tr>
        <s:if test="%{#session['s_userRole']=='Supervisor'}">
            <th>Select</th>
        </s:if>
        <th>Job ID</th>
        <th>Upload Date</th>
        <th>File Name</th>
        <th>Status</th>
        <th>Notes</th>
    </tr>
    <s:iterator value="jobs">
        <tr>
            <s:if test="%{#session['s_userRole']=='Supervisor'}">
                <td><s:checkbox name="check" /></td>
            </s:if>
            <td><s:property value="jobId" /></td>
            <td><s:property value="uploadDate" /></td>
            <td><a href=fileName><s:property value="fileName" /> </a></td>
            <td><s:property value="status" /></td>
            <td><a href='javascript:onClick=alert("Note goes here")'>View
                    Note</a></td>

        </tr>
    </s:iterator>
</table>

但它会在不同的行上显示复选框。如何将它带到同一行?

2 个答案:

答案 0 :(得分:6)

这是由于Struts2的默认渲染基于其默认主题。我发现本教程很好地介绍了Struts2主题/模板:http://www.mkyong.com/struts2/working-with-struts-2-theme-template/

如果您不希望使用默认模板进行渲染,请尝试:<s:checkbox name="check" theme="simple"/>

答案 1 :(得分:1)

刚刚放

<s:form theme="simple"></s:form>