/** * 解析字符串模板 * * @param template 字符串模板 * @param model 数据 * @return 解析后内容 */ public static String process(String template, Map<String, ?> model) throws IOException, TemplateException { Configuration configuration = null; ApplicationContext applicationContext = SpringUtils.getApplicationContext(); if (applicationContext != null) { FreeMarkerConfigurer freeMarkerConfigurer = SpringUtils.getBean("freeMarkerConfigurer", FreeMarkerConfigurer.class); if (freeMarkerConfigurer != null) { configuration = freeMarkerConfigurer.getConfiguration(); } } return process(template, model, configuration); }
private static void check() { if (configuration == null) { FreeMarkerConfigurer freeMarkerConfigurer = SpringUtils.getBean("freemarkerConfigurer"); if (freeMarkerConfigurer != null) { configuration = freeMarkerConfigurer.getConfiguration(); } else { ExceptionUtils.throwRuntimeException("spring has not freemarkerConfigurer"); } } }