Java Jasper报告:空报告

Java Jasper报告:空报告,java,html,xml,servlets,jasper-reports,Java,Html,Xml,Servlets,Jasper Reports,我试图通过发送参数生成带有Jasper Reports的PDF报告,但该报告始终为空,我在GlassFich中没有任何错误。另一个问题是报告的名称,当我编辑查询以添加参数时,我发现报告的名称为空。我搜索了很多,没有找到问题。请帮忙 index.html <form action="Task"> <input type="text" name="id" > </form> report1.xml <?xml version="1.0"

我试图通过发送参数生成带有Jasper Reports的PDF报告,但该报告始终为空,我在GlassFich中没有任何错误。另一个问题是报告的名称,当我编辑查询以添加参数时,我发现报告的名称为空。我搜索了很多,没有找到问题。请帮忙

index.html

  <form action="Task">
  <input type="text"  name="id" >
  </form>
report1.xml

  <?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="null" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="869aca66-1f7b-4e24-a8d8-090840222f22">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="parameter1" class="java.lang.Integer"/>
<queryString>
    <![CDATA[select * from task where id=$P{parameter1}]]>
</queryString>
<field name="id" class="java.lang.Integer">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="start_date" class="java.sql.Date">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="duration" class="java.lang.Integer">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="text" class="java.lang.String">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>

<background>
    <band splitType="Stretch"/>
</background>
<title>
    <band height="79" splitType="Stretch"/>
</title>
<columnHeader>
    <band height="61" splitType="Stretch">
        <staticText>
            <reportElement x="43" y="2" width="100" height="20" uuid="497fe8e3-98cf-4cd2-9841-11579f25a51b"/>
            <text><![CDATA[start_date]]></text>
        </staticText>
        <staticText>
            <reportElement x="195" y="2" width="100" height="20" uuid="d714a12d-4b7d-473f-adb3-34fb39eb99c5"/>
            <text><![CDATA[duration]]></text>
        </staticText>
        <staticText>
            <reportElement x="325" y="2" width="100" height="20" uuid="6cc1d4de-4bcc-45f0-b361-befd9b277e28"/>
            <text><![CDATA[text]]></text>
        </staticText>
        <staticText>
            <reportElement x="486" y="2" width="100" height="20" uuid="c5e7c67b-39c2-439b-971d-35f8d16bf6e6"/>
            <text><![CDATA[id]]></text>
        </staticText>
    </band>
</columnHeader>
<detail>
    <band height="125" splitType="Stretch">
        <textField>
            <reportElement x="43" y="19" width="100" height="20" uuid="e81d91a0-9a28-4609-9f7c-cf841e0475af"/>
            <textFieldExpression><![CDATA[$F{start_date}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="195" y="17" width="100" height="20" uuid="52ba1845-6feb-4ce0-b304-906c0c7c25df"/>
            <textFieldExpression><![CDATA[$F{duration}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="325" y="28" width="100" height="20" uuid="4d95ce91-4c97-482f-bb6b-880c3eab6b14"/>
            <textFieldExpression><![CDATA[$F{text}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="486" y="44" width="100" height="20" uuid="70b0a1b1-e6f8-4931-8afb-7ef4aedb5351"/>
            <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
        </textField>
    </band>
</detail>
在xml中编辑标记并设置name参数,此时您的参数name=null

更新:

报告中的参数名为parameter1,您输入了代码

Map param=new HashMap();
param.put("id", id);
试试这个:

Map param=new HashMap();
param.put("parameter1", id);
Map param=new HashMap();
param.put("parameter1", id);