JasperReport로 보고서 엔진을 만들고 있습니다. 지금까지는 모든 것이 잘 작동하지만 약간의 미스 이해가 있습니다. 내 코드에서 템플릿 파일을 컴파일하고 JasperReport 객체를 반환하고 컴파일이 실패한 경우 다른 파일을 컴파일하고 오류 메시지를 반환하려고합니다. 그러나 그것은 어떤 이유로 작동하지 않습니다. 여기 내 코드입니다 :JasperReport 예외 인쇄
/**
* Generates JasperPrint object from the Template file
* @param Template File Name (String)
* @param Parameters (Map<String, Object>)
* @param Collection of Value Objects (Collection, List, ArrayList)
* @return JasperPrint
*/
private JasperPrint getJRPrint(String tmpltFileLocation, Map<String, Object> params, JRBeanCollectionDataSource dataSource) {
JasperPrint jrPrint = null;
log.info("ReportEngine: compiling " + tmpltFileLocation);
try {
JasperReport jasperReport = JasperCompileManager.compileReport(tmpltFileLocation);
jrPrint = JasperFillManager.fillReport(jasperReport, params, dataSource);
} catch (JRException ex) {
ex.printStackTrace();
return getErrorJRPrint(ex);
}
return jrPrint;
}
private JasperPrint getErrorJRPrint(Exception ex) {
JasperPrint errJrPrint = null;
Map<String, Object> errParams = new HashMap<String, Object>();
errParams.put("errorMessage", ex.getMessage());
try {
JasperReport jasperReport = JasperCompileManager.compileReport(reportFolderName + "errReport.jrxml");
errJrPrint = JasperFillManager.fillReport(jasperReport, errParams);
} catch (Exception ex2) {
ex2.printStackTrace();
}
return errJrPrint;
}
오류 템플릿 파일이 (나는 그것을 삭제 시도하고 파일이 없음을 불평, 그래서 그것을 볼 수 있습니다). 내 템플릿 파일에서 나는 단지 오류 메시지를 출력하고 일부 정적 텍스트를 인쇄하려고했지만 작동하지 않습니다. 무엇이 문제 일 수 있습니까?
문제를 해결 했습니까? – Bozho