Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么datatable会添加更多<;td>;我的桌子_Java_Jsf - Fatal编程技术网

Java 为什么datatable会添加更多<;td>;我的桌子

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"/>

这是我的jsf:

 <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="&#160;" /><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>&nbsp;<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>&nbsp;<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="&#160;" /><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