在JSP中打印DataTable标头

时间:2013-12-22 13:27:05

标签: java jsp jsf jsf-2

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<h:dataTable value="#{personBean.addresses}" var="address" cellspacing="1" cellpadding="1" width="100%">
     <h:column>
         <f:facet name="header">Postcode</f:facet><br/>
         <h:outputText value="#{address.postcode}" />
     </h:column>
</h:dataTable>

有谁可以告诉我为什么打印每行的标题而不是只打印一次标题?

1 个答案:

答案 0 :(得分:1)

请改为尝试:

<h:dataTable value="#{personBean.addresses}" var="address" cellspacing="1" cellpadding="1" width="100%">
<h:column>
<f:facet name="header">
   <h:outputText value="Postcode" />
 </f:facet>
<h:outputText value="#{address.postcode}" />
</h:column>
</h:dataTable>