我正在尝试使用 JasperReports 创建报告,但是每当我运行脚本时,它总是会返回一个错误,指出发现以元素“queryString”开头的无效内容,我猜我没有在 queryString 元素中安排查询
这是jrxml代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="staff">
<field name="staffId" class="java.lang.String"/>
<field name="firstName" class="java.lang.String"/>
<field name="lastName" class="java.lang.String"/>
<field name="email" class="java.lang.String"/>
<field name="password" class="java.lang.String"/>
<queryString><![CDATA[select * from staff]]>
</queryString>
<pageHeader>
<band height="30">
<staticText>
<reportElement x="0" y="0" width="69" height="24"/>
<textElement verticalAlignment="Bottom"/>
<text>
<![CDATA[Staff ID: ]]>
</text>
</staticText>
<staticText>
<reportElement x="140" y="0" width="69" height="24"/>
<text>
<![CDATA[First Name: ]]>
</text>
</staticText>
<staticText>
<reportElement x="280" y="0" width="69" height="24"/>
<text>
<![CDATA[Last Name: ]]>
</text>
</staticText>
<staticText>
<reportElement x="420" y="0" width="69" height="24"/>
<text>
<![CDATA[Email: ]]>
</text>
</staticText>
<staticText>
<reportElement x="420" y="0" width="69" height="24"/>
<text>
<![CDATA[Password: ]]>
</text>
</staticText>
</band>
</pageHeader>
<detail>
<band height="30">
<textField>
<reportElement x="0" y="0" width="69" height="24"/>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{staffId}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="140" y="0" width="69" height="24"/>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{firstName}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="280" y="0" width="69" height="24"/>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{lastName}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="420" y="0" width="69" height="24"/>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{email}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="420" y="0" width="69" height="24"/>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{password}]]>
</textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
然后我删除了 Stringquery 元素和 JasperViewer 打开但没有内容。