java如何将jasper报告生成的PDF文件保存在一个项目文件夹中
我有一个jasper报告,用户已经可以下载了。 但现在需要将此PDF的副本保存到服务器上的特定文件夹中,我有以下代码,但它会生成一个错误
JasperDesign design = JRXmlLoader.load(jrxPath);
JasperReport report = JasperCompileManager.compileReport(design);
JasperPrint print = JasperFillManager.fillReport(report, getParametros());
//String pojectPath = "http://localhost:9080/ProjectName/";
String exportPath = projectPath + "reports/saida/" + "reportName.pdf";
JasperExportManager.exportReportToPdfFile(print, exportPath);
net.sf.jasperreports.engine.JRRuntimeException: java.io.FileNotFoundException: http:\localhost:9080\RelatoriosDPOC\reports\saida\reportName.pdf
(The syntax for the file name, directory name, or volume label is incorrect.)
我已经试着改变道路了。但我也犯了同样的错误
String exportPath = projectPath + "reports/saida/";
及
String exportPath = projectPath + "reports/saida";
我的项目文件夹:
# 1 楼答案
尝试创建一个目录并获取该目录的绝对路径: