使用文本字段值编辑器,我添加一个带有条件的文本到文本字段(注意 if 是使用 JasperSoft studio 的字段编辑器构建的,因此代码 IF(...) 是自动生成的,我只给出了值“pippo”并且“冥王星”)
"Some value" +IF(true,"pippo","pluto")
Run Code Online (Sandbox Code Playgroud)
但似乎不起作用。从我的代码调用报告时出现此错误:
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The method IF(boolean, String, String) is undefined for the type
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激
尝试使用ternary运算符而不是IF像下面这样
"Some value" + (value == true ? "pippo" : "pluto")
Run Code Online (Sandbox Code Playgroud)
希望这会对您有所帮助。
| 归档时间: |
|
| 查看次数: |
18823 次 |
| 最近记录: |