@Bean public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException { final FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory(); // If overwritten use path of user if (isNotBlank(uaaProperties.getTemplatePath())) { final TemplateLoader templateLoader = getTemplateLoader(uaaProperties.getTemplatePath()); factory.setPreTemplateLoaders(templateLoader); } // Default configurations factory.setPostTemplateLoaders(getTemplateLoader("classpath:/templates/")); factory.setDefaultEncoding("UTF-8"); final FreeMarkerConfigurer result = new FreeMarkerConfigurer(); result.setConfiguration(factory.createConfiguration()); return result; }
@Bean public FreeMarkerConfigurer getFreemarkerConfig() throws IOException, TemplateException { final FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory(); factory.setTemplateLoaderPath("/WEB-INF/views/"); factory.setDefaultEncoding("UTF-8"); final Properties properties = new Properties(); properties.put("auto_import", "spring.ftl as spring"); properties.put("template_exception_handler", "rethrow"); factory.setFreemarkerSettings(properties); final Map<String, Object> sharedVariables = new HashMap<String, Object>(); sharedVariables.put("include", this.freemarkerIncludeDirective); factory.setFreemarkerVariables(sharedVariables); factory.setPreferFileSystemAccess(false); final FreeMarkerConfigurer result = new FreeMarkerConfigurer(); // FIXME factory not working // result.setConfiguration(factory.createConfiguration()); result.setTemplateLoaderPath("/WEB-INF/views/"); result.setFreemarkerVariables(sharedVariables); result.setFreemarkerSettings(properties); return result; }
protected void applyProperties(FreeMarkerConfigurationFactory factory) { factory.setTemplateLoaderPaths(this.properties.getTemplateLoaderPath()); factory.setPreferFileSystemAccess(this.properties.isPreferFileSystemAccess()); factory.setDefaultEncoding(this.properties.getCharsetName()); Properties settings = new Properties(); settings.putAll(this.properties.getSettings()); factory.setFreemarkerSettings(settings); }
public FreeMarkerConfigurationFactory getFreeMarkerConfigurationFactory() { return freeMarkerConfigurationFactory; }
public void setFreeMarkerConfigurationFactory(FreeMarkerConfigurationFactory freeMarkerConfigurationFactory) { this.freeMarkerConfigurationFactory = freeMarkerConfigurationFactory; }
public FreeMarkerConfigurationFactory getConfigurationFactory() { return configurationFactory; }
public void setConfigurationFactory(FreeMarkerConfigurationFactory configurationFactory) { this.configurationFactory = configurationFactory; }