问题
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