Jasper REST传递集合作为参数 [英] Jasper REST pass collection as parameter
问题描述
我有一个报告,它接收一个List参数以在IN子句中使用它:
I have a report which receives a List parameter to use it in a IN clause:
$ X {IN,personID,_personID}
当通过iReport中的Web应用程序或远程存储库视图运行报告时,报告可以正常工作。
The report works when running it through the web application or remote repository view in iReport.
现在我需要使用REST api来调用它。我已经尝试了几种不同的方式在我的资源描述符中传递列表值,但没有一种方法有效。
Now I need to call it using the REST api. I have tried several different ways of passing the list value in my resource descriptor but none of them worked.
<resourceDescriptor name="Test_Report" wsType="reportUnit" uriString="/Test/Test_Report" isNew="false">
<parameter name="_personId" isListValue="true"><![CDATA[1]]></parameter>
</resourceDescriptor>
以上示例返回以下错误:
The above example returns the following error:
IN子句中使用的参数_personId的类型java.lang.String无效;值必须是数组或集合。
我还尝试以下操作:
<parameter>
<name>_personId</name>
<value isListValue="true">
3
</value>
</parameter>
但是这会返回包含所有记录的报告,而不仅仅是Id = 3的人。
But this returns a report with all the records, not only the person with Id=3.
推荐答案
我解决这个问题的方法是使用JasperServer的REST V2服务。
My workaround for this problem was to use the REST V2 services of JasperServer.
此外,V2比第一版服务有两个优点:
Added to this the V2 has two advantages over the first version of the service:
- 它不需要资源描述符
- 它运行并在一个GET请求中导出报告
运行所需的所有信息并导出报告通过请求URL传递,例如:
All the information required to run and export the report is passed through the request URL, for example:
< host> /rest_v2/reports/Test/TestReport.html? _personId = 3& _personId = 4& _personId = 5& _personId = 6
这篇关于Jasper REST传递集合作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!