JasperReports与Maven和Eclipse的例子

我想要的是使用JasperReport + Maven + Eclipse生成一个简单的pdf报告。

我一直在浏览一个简单的例子,但却找不到任何一个。

  1. JasperReport网站似乎没有Maven的任何教程
  2. Maven 2 JasperReports插件在生命周期配置未涵盖的Eclipse插件执行中出现以下错误:org.codehaus.mojo:jasperreports-maven-plugin:1.0-beta-2:compile-reports
  3. 其他网站上的大多数示例都是Ant和Jasper

它是一个获取数据的小报告。

这是你的控制器

@RequestMapping(value ="/BMIbyage",method = RequestMethod.GET) public ModelAndView BMIbyage(ModelAndView modelAndView, ModelMap model, Map map,HttpServletRequest request, @RequestParam("syear") int syear,@RequestParam("eyear") int eyear,HttpSession session){ String childid = (String) session.getAttribute("childid"); List asum = new ArrayList(); List patientdetail = patientService.listpatientbmi(); for(int i=syear;i<=eyear;i++){ asum.add(new AdmissionSummery()); int no=0; for(int j=0;j 

像这样的设计师页面 在此处输入图像描述

这是你的设计师xml

  <band height="122" splitType="Stretch"> <rectangle> <reportelement x="4" y="100" width="197" height="20"></reportelement> </rectangle> <textfield> <reportelement x="193" y="71" width="166" height="19"></reportelement> <textelement> <font size="14" isBold="true"></font> </textelement> <textfieldexpression class="java.lang.String"><![CDATA[$F{duration}]]></textfieldexpression> </textfield> <statictext> <reportelement x="5" y="9" width="526" height="37"></reportelement> <textelement textAlignment="Center"> <font size="14" isBold="true"></font> </textelement> <text><![CDATA[Paediatric Professional Unit -Ward 11 Teaching Hospital Jaffna]]></text> </statictext> <line> <reportelement x="5" y="92" width="550" height="1" forecolor="#CCCCCC"></reportelement> <graphicelement> <pen lineWidth="2.0"></pen> </graphicelement> </line> <statictext> <reportelement x="5" y="102" width="51" height="20"></reportelement> <textelement textAlignment="Center" verticalAlignment="Middle"> <font size="12" isBold="true"></font> </textelement> <text><![CDATA[Year]]></text> </statictext> <statictext> <reportelement x="5" y="53" width="526" height="46"></reportelement> <textelement> <font size="14" isBold="true"></font> </textelement> <text><![CDATA[ BMI value < 18.5kg/m2 -]]></text> </statictext> <statictext> <reportelement x="59" y="102" width="142" height="20"></reportelement> <textelement textAlignment="Center" verticalAlignment="Middle"> <font size="12" isBold="true"></font> </textelement> <text><![CDATA[Number of Admission]]></text> </statictext> <line> <reportelement x="56" y="100" width="1" height="20"></reportelement> </line> </band>                                     

这是你的JSP

  
BMI value < 18.5kg/m2 to

这是jasper-views.xml

  

这是pom.xml

   net.sf.jasperreports jasperreports 3.7.6 jar compile   commons-collections commons-collections   commons-beanutils commons-beanutils   commons-digester commons-digester   commons-logging commons-logging    

我希望这可以有所帮助