【问题标题】:Grails IReport Jasper returns blank pageGrails IReport Jasper 返回空白页
【发布时间】:2012-07-02 15:42:31
【问题描述】:

我遇到了这个问题,必须在我的 grails 应用程序上显示我的 jasper 报告。 在应用程序上,我使用以下命令安装了 jasper 插件:grails> install-plugin jasper 我创建了 sample.jrxml 具有这种上下文:

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="student" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="1.2100000000000002"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement x="181" y="0" width="212" height="37"/>
                <textElement textAlignment="Center">
                    <font size="24"/>
                </textElement>
                <text><![CDATA[Portal Student List]]></text>
            </staticText>
        </band>
    </title>
    <columnHeader>
        <band height="26"/>
    </columnHeader>
    <detail>
        <band height="98" splitType="Stretch"/>
    </detail>
    <columnFooter>
        <band height="43" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch">
            <staticText>
                <reportElement x="238" y="0" width="100" height="20"/>
                <textElement textAlignment="Center"/>
                <text><![CDATA[Copyright]]></text>
            </staticText>
        </band>
    </pageFooter>
</jasperReport>

我使用 Jasper 标记 &lt;g:jasperReport jasper="student" format="PDF"/&gt; 调用报告,或者创建一个新的闭包,使用此代码将 .pdf 文件直接显示到浏览器:

def report() {
        def reportDef = new JasperReportDef(folder: 'reports', name:'student.jrxml', fileFormat: JasperExportFormat.PDF_FORMAT)
        reportDef.contentStream = jasperService.generateReport(reportDef)

        response.contentType = reportDef.fileFormat.mimeTyp
        response.characterEncoding = 'UTF-8'
        response.outputStream << reportDef.contentStream.toByteArray()
}

使用的任何一种方法都返回一个空白页。

我该如何解决这个问题?

谢谢

【问题讨论】:

  • 你解决过这个问题吗?我有同样的问题:/
  • 只需按照 Grails 网站上 Jasper 的插件文档进行操作即可。
  • 如果您的意思是grails.org/plugin/jasper,那么我确实遵循了这一点。您能否分享相关的 BuildConfig.groovy 片段(“依赖项”和“插件”)?我不确定我是否使用了所有正确的版本,因为它不能通过添加“compile ':jasper:1.6.1'”来开箱即用。

标签: grails jasper-reports ireport


【解决方案1】:

我可能不得不解决这个link 中Grails 提供的教程以及Jasper 自己提供的示例here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-20
    • 1970-01-01
    • 2021-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多