我是用jasreport+ strut2做报表的,但是发现无论我绑定了还是没有没定数据源,在用浏览器访问时,页面上都没有东西,没有任何东西?
源代码:
strut2 配置:
 <result name="test" type="jasper">   
                <param name="location">/package4/report/report9.jasper</param>   
                <param name="dataSource">nucleusDeviceList</param> 
                <param name="format">PDF</param>    
            </result>   
pojo:
public class NucleusDevice {

@Id
@Column(name="nucleus_device_id")
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;

private String number;

private String unit;

private String name;

private String degree;

private String address;
}
get set 方法省略了Action中配置:
 public String test() {
this.pm = nucleusDeviceManager.selectNucleusDeviceList();
nucleusDeviceList = this.pm.getDatas();
for (Object o : nucleusDeviceList) {
NucleusDevice n = (NucleusDevice)o;
System.out.println(n.getName());
}
     return "test";
 }
报表设计:<?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="report9" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<field name="id" class="java.lang.String"/>
<field name="unit" class="java.lang.String"/>
<field name="name" class="java.lang.String"/>
<field name="degree" class="java.lang.String"/>
<field name="address" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="80" splitType="Stretch">
<staticText>
<reportElement x="117" y="10" width="262" height="27"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[核设施列表]]></text>
</staticText>
<staticText>
<reportElement x="2" y="51" width="100" height="20"/>
<textElement/>
<text><![CDATA[编号]]></text>
</staticText>
<staticText>
<reportElement x="102" y="51" width="100" height="20"/>
<textElement/>
<text><![CDATA[运营单位]]></text>
</staticText>
<staticText>
<reportElement x="202" y="51" width="100" height="20"/>
<textElement/>
<text><![CDATA[设施名称]]></text>
</staticText>
<staticText>
<reportElement x="302" y="50" width="100" height="20"/>
<textElement/>
<text><![CDATA[经纬度]]></text>
</staticText>
<staticText>
<reportElement x="402" y="50" width="55" height="20"/>
<textElement/>
<text><![CDATA[详细地址]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{id}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{unit}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="202" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="302" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{degree}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="402" y="0" width="55" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{address}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch"/>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
后台打印:
com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn Data source value for data source nucleusDeviceList was null