Jasper Reports中的图像表达式URL [英] Image expression URL in Jasper Reports

查看:1026
本文介绍了Jasper Reports中的图像表达式URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将图像嵌入到JasperReports jrxml文件中。我有这个目录结构。

  Tomcat Root 
webapps
报告
- >图片
- > company_logo.jpg
- >报告
- > sample.jasper
- > WEB-INF
- >类

我尝试这样做,认为这是相对于我的报告上下文根



< pre class =lang-xml prettyprint-override> < image>
< reportElement x =0y =0width =104height =40/>
< imageExpression class =java.lang.String>
<![CDATA [images / company_logo.jpg]]>
< / imageExpression>
< / image>

..这也是

 < image> 
< reportElement x =0y =0width =104height =40/>
< imageExpression class =java.lang.String>
<![CDATA [/ images / company_logo.jpg]]>
< / imageExpression>
< / image>

但它总是说从位置 JRLoader加载字节时出错



我试过这样做并且有效,但我有点困惑为什么我的前两次尝试没有。



这真的是你在JasperReports中嵌入图片的方式吗?你需要提供整条路径吗?我想应该有一个页面相对
的东西。

 < image> ; 
< reportElement x =0y =0width =104height =40/>
< imageExpression class =java.lang.String>
<![CDATA [http:// localhost:8080 / reports / images / company_logo.jpg]]>
< / imageExpression>
< / image>

我对正确的方法感到有点困惑。

解决方案

<![CDATA [../ images / company_logo.jpg]]> 应该做的特技。路径相对于.jasper文件。


I would like to embed an image into my JasperReports jrxml file. I have this directory structure.

Tomcat Root
 webapps
  reports
   -->images
    --> company_logo.jpg
   -->reports
    -->sample.jasper
   -->WEB-INF
    -->classes

And I tried doing this thinking that this is relative to my reports context root

<image>
 <reportElement x="0" y="0" width="104" height="40"/>
 <imageExpression class="java.lang.String">
  <![CDATA["images/company_logo.jpg"]]>
 </imageExpression>
</image>

..and this also

<image>
 <reportElement x="0" y="0" width="104" height="40"/>
 <imageExpression class="java.lang.String">
  <![CDATA["/images/company_logo.jpg"]]>
 </imageExpression>
</image>

but it always says there was an error loading bytes from location JRLoader.

I tried doing this and it works, but I am a bit confused why my first two attempt doesn't.

Is this really how you embed images in JasperReports? Do you need to supply the whole path? I am thinking that there should be a page relative something.

<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>

I am a bit puzzled about the correct way.

解决方案

<![CDATA["../images/company_logo.jpg"]]> should do the trick. The path is relative to your .jasper file.

这篇关于Jasper Reports中的图像表达式URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆