【问题标题】:Grails jasper parametersGrails jasper 参数
【发布时间】:2011-11-17 06:30:41
【问题描述】:

我正在使用 Jasper 插件进行报告。我需要将 3 个参数传递给 jrxml。在这 3 个参数中,两个是字符串,一个是列表。我在 jrxml 中定义相同。在我的 gsp 中,我正在传递这样的参数:

<input type="hidden" name="monthIndex" value="${month}" />
<input type="hidden" name="yearIndex" value="${year}" />
<input type="hidden" name="orgList" value="${orgInsList}"/>

这里orgInsList 是列表。当我像这样传递参数时,我会收到不兼容类型之类的错误。

【问题讨论】:

  • 您是否有机会发布实际错误而不是对错误的模糊回忆?
  • 我认为,这是因为您传递的是字符串,而不是列表
  • 是的。我想将列表传递给 jrxml。我该怎么做

标签: grails plugins jasper-reports


【解决方案1】:

在调用jasperService(而不是调用jasper 控制器)之前,对参数进行预处理。在 您的 控制器方法中使用如下内容:

params.orgList = params.orgList.tokenize(',')
def reportDef = jasperService.buildReportDefinition(params, request.getLocale(), [data: recordsList])
response.setHeader("Content-disposition", "attachment; filename=\"Report." + reportDef.fileFormat.extension + "\"");
response.contentType = reportDef.fileFormat.mimeTyp
response.characterEncoding = "UTF-8"
response.outputStream << reportDef.contentStream.toByteArray()

您需要在控制器中 def jasperService 以便 grails 为您注入依赖项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-25
    • 2017-09-25
    • 1970-01-01
    • 2013-02-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多