Spring mvc jasperreport html视图中的nullpx
我需要在我的web应用程序中使用报表。为此,我在iReport中设计了一个jrxml。我制作了一个空白的A4模板。我编写了该文件,然后将该jrxml文件放在我的类路径中。但当我选择html视图时,一个“X”图像正在该页面中显示。在ViewSource中,该元素被指定为Spring mvc jasperreport html视图中的nullpx,spring-mvc,jasper-reports,Spring Mvc,Jasper Reports,我需要在我的web应用程序中使用报表。为此,我在iReport中设计了一个jrxml。我制作了一个空白的A4模板。我编写了该文件,然后将该jrxml文件放在我的类路径中。但当我选择html视图时,一个“X”图像正在该页面中显示。在ViewSource中,该元素被指定为 <td><img alt="" src="nullpx" style="width: 46px; height: 1px;"/></td> 我的jsxml文件如下 <?xml ver
<td><img alt="" src="nullpx" style="width: 46px; height: 1px;"/></td>
我的jsxml文件如下
<?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="myreport" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a086f896-d28c-413e-8acc-416ff16d190a">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="clientName" class="java.lang.String"/>
<field name="currentBalance" class="java.lang.Float"/>
<field name="creditLimit" class="java.lang.Float"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="33" splitType="Stretch">
<staticText>
<reportElement uuid="bc001d2d-32f7-4222-8155-79f0ebd97aa3" x="26" y="2" width="100" height="20"/>
<textElement/>
<text><![CDATA[clientName]]></text>
</staticText>
<staticText>
<reportElement uuid="15f41fea-5cad-43b4-809b-7285fb9fea9f" x="201" y="2" width="100" height="20"/>
<textElement/>
<text><![CDATA[currentBalance]]></text>
</staticText>
<staticText>
<reportElement uuid="16d187cb-beb0-4799-bdcf-5bfdb1583626" x="416" y="2" width="100" height="20"/>
<textElement/>
<text><![CDATA[creditLimit]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="38" splitType="Stretch">
<textField>
<reportElement uuid="2cf8baa2-d1bc-46e2-a194-422d8d967f38" x="26" y="10" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{clientName}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="6c560e8a-8020-453c-9f5c-84cf9a964391" x="201" y="10" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{currentBalance}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="d8d431d9-8be9-46fb-bb43-3f4583c9c9e2" x="416" y="10" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{creditLimit}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
我是否可以在html页面中使用html而不删除任何图像。设置JRHtmlExporterParameter.Is\u使用“图像”将“对齐”属性设置为“false”将名为
net.sf.jasperreports.engine.export.JRHtmlExporterParameter的导出参数设置为false
:
例如:
<bean id="multiViewReport" class="org.springframework.web.servlet.view.jasperreports.JasperReportsMultiFormatView">
<property name="url" value="classpath:someJasperReport.jrxml" />
<!-- Set the ModelMap attribute "reportDataKey" to the JRDataSourceProvider -->
<property name="reportDataKey" value="reportDSProvider" />
<property name="exporterParameters">
<map>
<entry
key="net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN">
<value>false</value>
</entry>
</map>
</property>
</bean>
这个控制器允许我通过将格式类型附加到基本url来生成不同的报告格式
例如:
PS:我用SpringWebMVC3.2.1.RELEASE和Jasperreports4.5.1测试了这一点
@RequestMapping(value = "/report/{format}", method = RequestMethod.GET)
public String printWelcome(ModelMap model, @PathVariable(value = "format") String format) {
JRDataSourceProvider jrDataSourceProvider = .....;
model.addAttribute("format", format);
model.addAttribute("reportDSProvider", jrDataSourceProvider);
return "multiViewReport";
}