我遇到了将数据表导出为 pdf 的问题。我用:
<primeFacesVersion>3.5</primeFacesVersion>
和:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
<scope>provided</scope>
</dependency>
在 xhtml 中:
<h:form id="listForm">
<h:panelGrid width="100%" columns="1">
<p:dataTable id="listTable" var="employee"
value="#{employeeBean.result}" paginator="true" dynamic="true"
rows="10" rowKey="#{item.id}" rowIndexVar="i" selection="#{employeeBean.selected}"
emptyMessage="#{label['no.record.found']}" sortDescMessage="#{label['sort.desc.message']}"
paginatorPosition="bottom" sortAscMessage="#{label['sort.asc.message']}"
update="listTable">
.....
<h:commandLink value="#{label['PDF']}" ajax="false" icon="excel-icon">
<p:dataExporter type="pdf" target="listTable" fileName="emplList"/>
</h:commandLink>
</h:form>
抛出这个异常是行不通的:
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [] threw exception [com/lowagie/text/Phrase] with root cause
java.lang.ClassNotFoundException: com.lowagie.text.Phrase