Java 为什么datatable会添加更多<;td>;我的桌子
这是我的jsf:Java 为什么datatable会添加更多<;td>;我的桌子,java,jsf,Java,Jsf,这是我的jsf: <h:dataTable class="pretty" value="#{ftController.ftDataModel}" var="item"> <h:column> <f:facet name="header"> <h:outputText value="Amount"/>
<h:dataTable class="pretty" value="#{ftController.ftDataModel}" var="item">
<h:column>
<f:facet name="header">
<h:outputText value="Amount"/>
</f:facet>
</h:column>
<h:column >
<f:facet class="right" name="header">
<h:outputText value="Date"/>
</f:facet>
</h:column>
<h:column>
<h:outputLink value="index.jsf"><h:outputText value="#{item.ftType}"/></h:outputLink><br />
<h:outputText class="red" id="amount" value="#{item.amount}"></h:outputText> <h:outputText value=" " /><h:outputText style="font-size:12px" class="gray" value="TL" />
</h:column>
<h:column class="right" >
<h:outputText id="date" value="#{item.date}"></h:outputText>
</h:column>
</h:dataTable>
然而,html输出是这样的:
<table class="pretty">
<thead>
<tr>
<th scope="col">Amount</th>
<th scope="col">Date</th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td><a href="index.jsf" class="ui-link">Person</a><br><span id="j_idt8:j_idt21:0:amount" class="red">34500.6</span> <span class="gray" style="font-size:12px">TL</span></td>
<td><span id="j_idt8:j_idt21:0:date">10/14/2012</span></td>
</tr>
<tr>
<td></td>
<td></td>
<td><a href="index.jsf" class="ui-link">Person</a><br><span id="j_idt8:j_idt21:1:amount" class="red">3444.78</span> <span class="gray" style="font-size:12px">TL</span></td>
<td><span id="j_idt8:j_idt21:1:date">10/15/2012</span></td>
</tr>
</tbody>
</table>
数量
日期
34500.6泰尔
10/14/2012
3444.78泰尔
10/15/2012
它在金额和日期下为ex添加额外的
。它还添加了s
为什么?这里有什么问题?我怎样才能解决它?为什么要添加?这是因为数据表中有4个
。第三个和第四个没有name属性,因此它是空的。只需将
与行数据一起嵌套在
中即可。您在代码中告诉JSF的是创建4列,其中前两列包含空行数据和定义的标题文本,后两列包含所有内容。将其修复为:
<h:dataTable class="pretty" value="#{ftController.ftDataModel}" var="item">
<h:column>
<f:facet name="header">
<h:outputText value="Amount"/>
</f:facet>
<h:outputLink value="index.jsf"><h:outputText value="#{item.ftType}"/></h:outputLink><br />
<h:outputText class="red" id="amount" value="#{item.amount}"></h:outputText> <h:outputText value=" " /><h:outputText style="font-size:12px" class="gray" value="TL" />
</h:column>
<h:column >
<f:facet class="right" name="header">
<h:outputText value="Date"/>
</f:facet>
<h:outputText id="date" value="#{item.date}"></h:outputText>
</h:column>
</h:dataTable>
因此您面临什么问题?它只是数据表的HTNL源<代码>列方面=HTML th
和列
=HTML td
这是预期的行为。您定义了4个
。因此,它添加了4
和4
。