Struts渲染我的表错了

时间:2015-01-14 10:23:37

标签: java html struts2

有人可以告诉我,为什么我的表格会被错误地表达出来?

<table class="ListingTable">
        <thead>
            <tr>
                <th style="border-left-style: hidden;">ProjectName</th>
                <th>CustomerID</th>
                <th>Leader</th>
                <th>DeadLine</th>
                <th>Status</th>
                <th style="border-right-style: hidden;"></th>
            </tr>
        </thead>
        <tbody>
            <s:iterator value="projectMaps" status="Statusindex">
                <tr>
                    <td><s:property value="Name" /></td>
                    <td><s:property value="CustomerID" /></td>
                    <td><s:property value="Leader" /></td>
                    <td><s:property value="DeadLine" /></td>
                    <td><s:property value="Status" /></td>
                    <td>
                        <form action="Details.action">
                            <s:hidden id="statusid" name="statusid" value="%{Index}" />
                            <s:submit type="submit" id="%{Index}" value="Details"
                                method="execute" style="height:20px;" />
                        </form>
                    </td>
                </tr>
            </s:iterator>
        </tbody>
    </table>

应该如下所示: The pic, of what it should look like

但它看起来像这样:

How it actually looks

它必须在<form> </form>范围内,因为如果我将其注释掉并用一个Button替换它,我会从第一张图片中得到结果。

它会为每个按钮创建一个新的<tr>额外内容,我不明白!

3 个答案:

答案 0 :(得分:1)

使用simple主题来阻止框架生成额外的<tr>

<s:submit type = "submit" 
            id = "%{Index}" 
         value = "Details"
        method = "execute" 
      cssStyle = "height:20px;" 
         theme = "simple" />

另外,style应该是Struts标记中的cssStyle

最后,避免使用DMI(动态方法调用,method=""部分),因为它非常不鼓励。如果方法是execute()(默认方法),则甚至不需要它。

详细了解设置主题in this answer的不同方法。

答案 1 :(得分:0)

在表单显示中添加样式:inline-block;

<form action="Details.action" style="display: inline-block;">

答案 2 :(得分:0)

将表格放在桌子外面。像这样的东西

<form>
   <table>
      ....
   </table>
</form>

我认为提交按钮中没有使用style="height:20px;"

相关问题