【发布时间】:2010-09-02 02:17:42
【问题描述】:
我想将图像嵌入到我的 JasperReports jrxml 文件中。我有这个目录结构。
Tomcat Root
webapps
reports
-->images
--> company_logo.jpg
-->reports
-->sample.jasper
-->WEB-INF
-->classes
我尝试这样做,认为这与我的报告上下文根相关
<image>
<reportElement x="0" y="0" width="104" height="40"/>
<imageExpression class="java.lang.String">
<![CDATA["images/company_logo.jpg"]]>
</imageExpression>
</image>
..这也是
<image>
<reportElement x="0" y="0" width="104" height="40"/>
<imageExpression class="java.lang.String">
<![CDATA["/images/company_logo.jpg"]]>
</imageExpression>
</image>
但它总是说从位置 JRLoader 加载字节时出错。
我尝试这样做并且它有效,但我有点困惑为什么我的前两次尝试没有。
这真的是您在 JasperReports 中嵌入图像的方式吗?您需要提供整个路径吗?我在想应该有一个相对的页面 东西。
<image>
<reportElement x="0" y="0" width="104" height="40"/>
<imageExpression class="java.lang.String">
<![CDATA["http://localhost:8080/reports/images/company_logo.jpg"]]>
</imageExpression>
</image>
我对正确的方法有点困惑。
【问题讨论】:
标签: jasper-reports