Struts2 struts 2中使用xml文件作为数据源创建ireport时面临的问题
您好,朋友们,我正在尝试在struts 2中使用xpath数据源使用ireport创建报告,但当我执行操作时,它工作正常,我的报告格式也正常,但包含空值 这是我的动作课 下面是Struts.xml中报告的配置Struts2 struts 2中使用xml文件作为数据源创建ireport时面临的问题,struts2,ireport,Struts2,Ireport,您好,朋友们,我正在尝试在struts 2中使用xpath数据源使用ireport创建报告,但当我执行操作时,它工作正常,我的报告格式也正常,但包含空值 这是我的动作课 下面是Struts.xml中报告的配置 /WEB-INF/classes/org/gea/report/pf/pfStatement.jasper “/WEB-INF/classes/org/gea/report/pf/PfStatementXML.xml” PDF 报告参数 PF声明 请帮助我设置此问题。数据源元素应该是一
/WEB-INF/classes/org/gea/report/pf/pfStatement.jasper
“/WEB-INF/classes/org/gea/report/pf/PfStatementXML.xml”
PDF
报告参数
PF声明
请帮助我设置此问题。数据源元素应该是一个EL表达式,根据
如果您试图以其他方式填充/运行报告,则不适合使用插件。该插件专门用于直接从Struts 2操作获取数据,并将其公开给JasperReports,而无需任何中间步骤。根据
如果您试图以其他方式填充/运行报告,则不适合使用插件。该插件专门用于直接从Struts 2操作获取数据,并将其公开给JasperReports,无需任何中间步骤。您是否使用参数填充报表?在报表参数中,一个包含图像路径,另一个包含用作报表查询的参数AP我这样做了,我在简单mvc中这样做了,工作正常,但不起作用对于struts 2,我所做的一切是否正确Alex?您没有发布类声明,因此我认为您忘记了传递参数。您是否用参数填充报表?在报表参数中,一个包含图像路径,另一个包含用作报表查询的参数AP我做了,我在简单的mvc中做了,工作正常,但没有问题使用struts 2我所做的一切是否正确Alex??您不发布类声明,因此我认为您忘记了传递参数。
public String execute() throws Exception {
Connectionhandler.establishConnection();
ForReports fr = new ForReports();
//Creating Servlet Context
ServletContext context = ServletActionContext.getServletContext();
//Creating Source XML file
fr.getFinalResult(Connectionhandler.con, (2009 + stmtYear), empId, context);
Connectionhandler.closeConnection();
try {
// adding parameters
reportParams.put("imgPath", context.getRealPath("/images"));
//Contains Report Query
reportParams.put("REPORT_QUERY", "/main/employee/nomineelst/nominee");
//Compiling Report
JasperCompileManager.compileReportToFile(
context.getRealPath("/WEB-INF/classes/org/gea/report/pf/pfStatement.jrxml"),
context.getRealPath("/WEB-INF/classes/org/gea/report/pf/pfStatement.jasper"));
}catch(Exception e){
e.printStackTrace();
}
return SUCCESS;
}
<action name="getReport" class="org.gea.action.pf.GenerateReport">
<result name="success" type="jasper">
<param name="location">/WEB-INF/classes/org/gea/report/pf/pfStatement.jasper</param>
<param name="dataSource">"/WEB-INF/classes/org/gea/report/pf/PfStatementXML.xml"</param>
<param name="format">PDF</param>
<param name="reportParameters">reportParams</param>
<param name="documentName">PF Statement</param>
</result>
</action>