最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jasper reports - How to display a text when a image is not found in JRXML? - Stack Overflow

programmeradmin0浏览0评论

I am rendering an image in an HTML report using the following jrxml code:

         <image isLazy="true" onErrorType="Blank">
            <reportElement mode="Transparent" x="0" y="0" width="400" height="40"/>
            <imageExpression class="java.lang.String"><![CDATA[$P{iconURL}]]></imageExpression>
        </image>

The iconURL is the image file path. In some cases, the image file is not rendered throwing a 404 : fileNotFound exception. My use case is to display a text like "XYZ Report" when the image is not found.

I tried checking whether the image exists from the script side code and assigning a parameter accordingly, But in cases where the server is hosted in a different machine and it is accessed from another machine, the code checks whether the image file is present in the server machine rather than checking in the current working machine.

Is there any way to display a text when the image file is not found? Thanks in Advance.

发布评论

评论列表(0)

  1. 暂无评论