Jasper REST pass collection as parameter

断了今生、忘了曾经 提交于 2019-12-10 20:54:49

问题


I have a report which receives a List parameter to use it in a IN clause:

$X{IN, personID, _personID}

The report works when running it through the web application or remote repository view in iReport.

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:

Invalid type java.lang.String for parameter _personId used in an IN clause; the value must be an array or a collection.

I have also try the following:

<parameter>
<name>_personId</name>
<value isListValue="true">
    3
</value>
</parameter>

But this returns a report with all the records, not only the person with Id=3.


回答1:


My workaround for this problem was to use the REST V2 services of JasperServer.

Added to this the V2 has two advantages over the first version of the service:

  • it doesn't require a resource descriptor
  • it runs and exports the report in a single GET request

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



来源:https://stackoverflow.com/questions/18701170/jasper-rest-pass-collection-as-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!