JasperReport子报表采用JavaBean做数据源的问题 5
用struts2和JasperReport和ireport做报表开发,其中用JavaBean做数据源,开发子报表时子报表的datasourceexpression为:ne...
用struts2和JasperReport和ireport做报表开发,其中用JavaBean做数据源,开发子报表时子报表的data source expression为:new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{majors}),但是运行后一直报错,错误为:net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{majors}),希望大家能帮我解决! 展开
Source text : new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{majors}),希望大家能帮我解决! 展开
2个回答
展开全部
主报表添加参数majors,如果是list,参数类型选为java.util.List,将子报表的data source expression改为:new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{majors}),在action中添加public Map<String,Object> reportParameter = new HashMap<String,Object>();及对应的set,get方法,将查询出的majors的值放入reportParameter,在struts.xml中配置如下:
<action name="pdf" class="com.xxxxx.action" >
<result name="Success" type="jasper">
<param name="location">/reports/main.jasper</param>
<param name="dataSource">list</param>
<param name="reportParameters">reportParameter</param>
<param name="format">PDF</param>
</result>
</action>
<action name="pdf" class="com.xxxxx.action" >
<result name="Success" type="jasper">
<param name="location">/reports/main.jasper</param>
<param name="dataSource">list</param>
<param name="reportParameters">reportParameter</param>
<param name="format">PDF</param>
</result>
</action>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询