[英]p:dataExporter throws java.lang.NoClassDefFoundError: com/lowagie/text/phrase
I tried to use the data exporter control of primefaces 3.2.我尝试使用primefaces 3.2的data exporter控件。 Following is the code:以下是代码:
<p:commandLink value="export" ajax="false">
<p:dataExporter type="xls" target="dtable" fileName="myfile" />
</p:commandLink>
<p:datatable id="dtable" ........../>
When I click on export link, I get the following error:当我单击导出链接时,出现以下错误:
java.lang.NoClassDefFoundError: com/lowagie/text/phrase
I downloaded itext jar 5.2.1 and included it in my application, still I get the same error.我下载了 itext jar 5.2.1 并将其包含在我的应用程序中,但我仍然遇到同样的错误。 How do I solve it?我该如何解决?
Try iText 2.1.7 not 5.2.1. 尝试iText 2.1.7而不是5.2.1。 http://olex.openlogic.com/packages/itext/2.1.7 http://olex.openlogic.com/packages/itext/2.1.7
I think there are licence conflicts. 我认为有许可证冲突。 So primefaces uses 2.1.7 所以primefaces使用2.1.7
For Excel Export you need Apache POI. 对于Excel Export,您需要Apache POI。 Try 3.7: http://archive.apache.org/dist/poi/release/bin/ 尝试3.7: http : //archive.apache.org/dist/poi/release/bin/
Edit 编辑
(you need only the poi-3.7*.jar
and poi-ooxml-3.7*.jar
) (你只需要poi-3.7*.jar
和poi-ooxml-3.7*.jar
)
Go to netbeans, on your project dependency add a new dependency. 转到netbeans,对项目依赖项添加新的依赖项。 Type Query type iText 2.1.7 then choose com.lowagie:itext. 键入查询类型iText 2.1.7然后选择com.lowagie:itext。 you should be able to download with dpf :D 你应该可以用dpf:D下载
Copie este código para o pom.xml复制代码 para o pom.xml
<dependency>
<groupId>org.eclipse.birt.runtime.3_7_1</groupId>
<artifactId>com.lowagie.text</artifactId>
<version>2.1.7</version>
</dependency>
E assim ficou o xhtml E assim ficou o xhtml
<h:commandLink>
<img src="/img/icones/excel.png"/>
<p:dataExporter type="xlsx" target="tbl" fileName="#{relatorioController.relatorio.nome}" />
</h:commandLink>
<p:spacer width="10"/>
<h:commandLink>
<img src="/img/icones/pdf.png"/>
<p:dataExporter type="pdf" target="tbl" fileName="#{relatorioController.relatorio.nome}"/>
</h:commandLink>
Just add the following dependency 只需添加以下依赖项
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
I was having the same problem, but when i downloaded the jars it doesn't worked. 我遇到了同样的问题,但是当我下载罐子时它没有用。 Then I noticed I was using <p:commandLink>
, the correct is to use <h:commandLink>
for some reason <p:commandLink>
won't work. 然后我注意到我正在使用<p:commandLink>
,正确的是使用<h:commandLink>
由于某种原因<p:commandLink>
将无法正常工作。
Don't use: 不要使用:
<p:commandLink > <p:graphicImage value="images/excel.png" width="48"/> <p:dataExporter type="xls" target="table" fileName="tablexls" encoding="UTF-8" /> </p:commandLink>
instead use: 改为使用:
<h:commandLink > <p:graphicImage value="images/custom/excel.png" width="48"/> <p:dataExporter type="xls" target="table" fileName="tablexls" encoding="UTF-8" /> </h:commandLink>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.