List of usage examples for org.springframework.ui.freemarker FreeMarkerConfigurationFactoryBean setTemplateLoaderPath
public void setTemplateLoaderPath(String templateLoaderPath)
From source file:com.sisrni.config.FreeMarkerConfig.java
@Bean public FreeMarkerConfigurationFactoryBean getFreeMarkerConfiguration() { FreeMarkerConfigurationFactoryBean bean = new FreeMarkerConfigurationFactoryBean(); bean.setTemplateLoaderPath("/WEB-INF/freemarker/"); return bean;//from ww w .j ava2s . c o m }
From source file:nl.surfnet.coin.selfservice.service.impl.EmailServiceImplTest.java
@Before public void setUp() throws Exception { emailService = new EmailServiceImpl(); FreeMarkerConfigurationFactoryBean freemarkerFactory = new FreeMarkerConfigurationFactoryBean(); freemarkerFactory.setTemplateLoaderPath("classpath:/ftl/"); freemarkerConfiguration = freemarkerFactory.createConfiguration(); emailService.setFreemarkerConfiguration(freemarkerConfiguration); MockitoAnnotations.initMocks(this); }
From source file:org.hdiv.web.servlet.view.freemarker.FreeMarkerConfigurerTests.java
public void testFreeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); fcfb.afterPropertiesSet();//from w w w . j a v a 2 s . co m Configuration cfg = (Configuration) fcfb.getObject(); assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader); }
From source file:org.hdiv.web.servlet.view.freemarker.FreeMarkerConfigurerTests.java
public void testFreemarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() throws IOException, TemplateException { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); Properties settings = new Properties(); settings.setProperty("localized_lookup", "false"); fcfb.setFreemarkerSettings(settings); fcfb.setResourceLoader(new ResourceLoader() { public Resource getResource(String location) { if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) { throw new IllegalArgumentException(location); }//from w ww .j a va 2 s.c o m return new ByteArrayResource("test".getBytes(), "test"); } public ClassLoader getClassLoader() { return getClass().getClassLoader(); } }); fcfb.afterPropertiesSet(); assertTrue(fcfb.getObject() instanceof Configuration); Configuration fc = (Configuration) fcfb.getObject(); Template ft = fc.getTemplate("test"); assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap())); }