Struts 渲染我的 table 错误
Struts rendering my table wrong
谁能告诉我,为什么我的 Table 渲染错误?
<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>
它应该是这样的:
但看起来像这样:
它必须在 <form> </form>
内,因为如果我将其注释掉并仅用一个按钮替换它,我会得到第一张图片的结果。
它为每个按钮创建了一个新的 <tr>
extra,我不明白!
为表单显示添加样式:inline-block;
<form action="Details.action" style="display: inline-block;">
将表格放在 table 之外。像这样
<form>
<table>
....
</table>
</form>
而且我认为在提交按钮中没有使用 style="height:20px;"
。
使用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。
谁能告诉我,为什么我的 Table 渲染错误?
<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>
它应该是这样的:
但看起来像这样:
它必须在 <form> </form>
内,因为如果我将其注释掉并仅用一个按钮替换它,我会得到第一张图片的结果。
它为每个按钮创建了一个新的 <tr>
extra,我不明白!
为表单显示添加样式:inline-block;
<form action="Details.action" style="display: inline-block;">
将表格放在 table 之外。像这样
<form>
<table>
....
</table>
</form>
而且我认为在提交按钮中没有使用 style="height:20px;"
。
使用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。