private static Configuration freemarkerCfg = null; static { freemarkerCfg = new Configuration(); //freemarker的模板目录 try { String pathPrefix = "/"; // 为了支持能从execute jar 中获取模板文件 URI uri = ClassUtils.getDefaultClassLoader().getResource("week-report-template.html").toURI(); if (uri.getScheme().equals("jar")) { pathPrefix = "/BOOT-INF/classes/"; } freemarkerCfg.setClassForTemplateLoading(WeekPdfReportUtil.class.getClass(), pathPrefix); freemarkerCfg.setClassicCompatible(true); } catch (Exception e) { e.printStackTrace(); } } //使用 String content = WeekPdfReportUtil.freeMarkerRender(data, "week-report-template.html");
com.itextpdf itextpdf 5.5.11 com.itextpdf.tool xmlworker 5.5.11 org.freemarker freemarker 2.3.19