【问题标题】:Print DataTable Headers in JSP在 JSP 中打印数据表标题
【发布时间】:2013-12-22 13:27:05
【问题描述】:
<%@ 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>

谁能告诉我为什么这会打印每行的标题,而不是只打印一次标题?

【问题讨论】:

    标签: java jsp jsf jsf-2


    【解决方案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>
    

    【讨论】:

    • NetBeans 警告我:#{...} not allowed in a template text body. 当我运行它时,我收到错误 org.apache.jasper.JasperException: /results.jsp(72,30) PWC6228: #{...} not allowed in a template text body.
    • 谢谢,它确实有效。不过只有一个问题,你知道为什么当我使用&lt;h:column headerClass="col1"&gt;&lt;h:outputText value="#{address.postcode}" /&gt; 的样式也不一样吗?
    • 使用风格:
    猜你喜欢
    • 1970-01-01
    • 2019-08-13
    • 1970-01-01
    • 1970-01-01
    • 2011-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-17
    相关资源
    最近更新 更多