gpt4 book ai didi

java - 如何在Jasper BLOB Image中显示?

转载 作者:行者123 更新时间:2023-11-30 02:42:24 25 4
gpt4 key购买 nike

我正在尝试将图像添加到我的 jasperReport,但它不起作用,它在调用时停止:

JasperRunManager.runReportToPdf ....

我在数据库中有 BLOB 类型的图像,在“file.jrxml”中我将其设置为

字段 --> IMAGE_FILE

FIELDCLASS --> oracle.sql.blob。

<小时/>

和图像属性:

图像表达式 -> $F{IMAGE_FILE}.getBinaryStream()

表达式类 -> java.lang.String

<小时/>

消息错误:

12:22:24,863 INFO  [STDOUT] 12:22:24,862 ERROR [JRFillSubreport] Fill 1: exception
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $F{IMAGE_FILE}.getBinaryStream()
...
...
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'oracle.sql.BLOB@5d17f1ea' with class 'oracle.sql.BLOB' to class 'oracle.sql.BLOB'
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599)
...
...
12:22:24,863 ERROR [STDERR] net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $F{IMAGE_FILE}.getBinaryStream()
<小时/>

所以主要错误无法解决,也找不到原因:

12:22:24,868 ERROR [STDERR] Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : 
Source text : $F{IMAGE_FILE}.getBinaryStream()
12:22:24,869 ERROR [STDERR] Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'oracle.sql.BLOB@5d17f1ea' with class 'oracle.sql.BLOB' to class 'oracle.sql.BLOB'

最佳答案

我找到了答案。只需修改这两个值即可:

* field : IMAGE_FILE
* field Class : oracle.sql.inputStream
<小时/>

以及新的图像属性:

*image expresion : $F{IMAGE_FILE}
*expression class : java.lang.String

关于java - 如何在Jasper BLOB Image中显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41261837/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com