问题描述
< table class =ListingTable> 有人可以告诉我,为什么我的表格显示错误吗? ;
< thead>
< tr>
< th style =border-left-style:hidden;> ProjectName< / th>
< th> CustomerID< / th>
Leader< / th>
th DeadLine< / th>
< th>状态< / th>
< th style =border-right-style:hidden;>< / th>
< / tr>
< / thead>
< tbody>
< s:iterator value =projectMapsstatus =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:属性值=状态/>< / td>
< td>
< form action =Details.action>
< s:submit type =submitid =%{Index}value =Details
method =executestyle =height:20px; />
< / form>
< / td>
< / tr>
< / s:iterator>
< / tbody>
< / table>
它应该是这样的:
但看起来像这样:
它必须在< form> < / form>
,因为如果我将它注释掉并用一个Button替换它,我会从第一张图片中得到结果。
它会为每个按钮创建一个新的< tr>
额外值,这是我不理解的!
简单
主题来防止框架生成额外的< tr>
:$ b
< s:submit type =submit
id =% {Index}
value =Details
method =execute
cssStyle =height:20px;
theme =简单/>
另外 style
应该是 cssStyle
在Struts标签中。
最后,避免使用DMI(动态方法调用, method =
部分),因为它非常不鼓励。如果方法是 execute()
,那么甚至不需要它是默认的。
阅读更多关于不同的在此答案中设置主题的方法。
Can someone Tell me, why my Table is rendered the wrong way?
<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>
It should look like this:
But it looks like this:
It must be within the <form> </form>
because if I comment it out and replace it with just a Button, I get the result from the first picture.
It creates a new <tr>
extra for each button, which I don't understand!
Use the simple
theme to prevent the framework from generating the extra <tr>
:
<s:submit type = "submit"
id = "%{Index}"
value = "Details"
method = "execute"
cssStyle = "height:20px;"
theme = "simple" />
Also style
should be cssStyle
in Struts Tags.
And finally, avoid using DMI (Dynamic Method Invocation, the method=""
part) because it is highly discouraged. It is not even needed if the method is execute()
, the default one.
Read more about the different ways to set a theme in this answer.
这篇关于Struts渲染我的表错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!