2
我想用JasperReports創建報告,但是每當我運行腳本時,它總是會回覆一個錯誤,指出發現了無效的內容,以元素'queryString'開頭,我猜我沒有安排在查詢字符串元素在jrxml文件中的查詢不起作用
這裏的查詢是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 elemnt和JasperViewer運行結束,但沒有內容。