日期:2014-05-17 浏览次数:21559 次
public String reportHTML() throws Exception { try { order = orderDao.findByOrderId(order.getOrderId()); //order = orderDao.findByCustomer(); String reportSource; reportSource = ServletActionContext.getServletContext() .getRealPath("/jasper/report1.jrxml"); File parent = new File(reportSource).getParentFile(); //将.jrxml模板文件编译成为.jasper文件,当然,其文件名可以指定,如果没指定,则与.jrxml文件名一样.只是后缀不同而已 JasperCompileManager.compileReportToFile(reportSource, new File(parent, "report1.jasper").getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); return ERROR; } return SUCCESS; }
<package name="default" namespace="/report" extends="shop.front,jasperreports-default"> <action name="order_*" class="orderAction" method="{1}"> <result name="success" type="jasper"> <param name="location"> /jasper/report1.jasper </param> <param name="dataSource">order</param> <param name="format">HTML</param> </result> <interceptor-ref name="customerDefaultStack"/> </action> </package>