Java Code Examples for org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer#setTemplateLoaderPath()
The following examples show how to use
org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer#setTemplateLoaderPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SmartGlobalErrorController.java From super-cloudops with Apache License 2.0 | 5 votes |
@Override public void afterPropertiesSet() throws Exception { if (log.isInfoEnabled()) { log.info("Initializing smart global error controller ..."); } try { FreeMarkerConfigurer fmcr = new FreeMarkerConfigurer(); fmcr.setTemplateLoaderPath(config.getBasePath()); Properties settings = new Properties(); settings.setProperty("template_update_delay", "0"); settings.setProperty("default_encoding", "UTF-8"); settings.setProperty("number_format", "0.####"); settings.setProperty("datetime_format", "yyyy-MM-dd HH:mm:ss"); settings.setProperty("classic_compatible", "true"); settings.setProperty("template_exception_handler", "ignore"); fmcr.setFreemarkerSettings(settings); fmcr.afterPropertiesSet(); // Initial errors template. Configuration fmc = fmcr.getConfiguration(); if (!isErrorRedirectURI(config.getNotFountUriOrTpl())) { this.tpl404 = fmc.getTemplate(config.getNotFountUriOrTpl(), UTF_8.name()); notNull(tpl404, "Default 404 view template must not be null"); } if (!isErrorRedirectURI(config.getUnauthorizedUriOrTpl())) { this.tpl403 = fmc.getTemplate(config.getUnauthorizedUriOrTpl(), UTF_8.name()); notNull(tpl403, "Default 403 view template must not be null"); } if (!isErrorRedirectURI(config.getErrorUriOrTpl())) { this.tpl50x = fmc.getTemplate(config.getErrorUriOrTpl(), UTF_8.name()); notNull(tpl50x, "Default 500 view template must not be null"); } } catch (Exception e) { throw new IllegalStateException(e); } }
Example 2
Source File: MolgenisWebAppConfig.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
/** * Configure freemarker. All freemarker templates should be on the classpath in a package called * 'freemarker' */ @Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer result = new FreeMarkerConfigurer() { @Override protected void postProcessConfiguration(Configuration config) { config.setObjectWrapper(new MolgenisFreemarkerObjectWrapper(VERSION_2_3_23)); } @Override protected void postProcessTemplateLoaders(List<TemplateLoader> templateLoaders) { templateLoaders.add(new ClassTemplateLoader(FreeMarkerConfigurer.class, "")); } }; result.setPreferFileSystemAccess(false); result.setTemplateLoaderPath("classpath:/templates/"); result.setDefaultEncoding("UTF-8"); Properties freemarkerSettings = new Properties(); freemarkerSettings.setProperty(Configuration.LOCALIZED_LOOKUP_KEY, Boolean.FALSE.toString()); freemarkerSettings.setProperty(Configuration.NUMBER_FORMAT_KEY, "computer"); result.setFreemarkerSettings(freemarkerSettings); Map<String, Object> freemarkerVariables = Maps.newHashMap(); freemarkerVariables.put("hasPermission", new HasPermissionDirective(permissionService)); freemarkerVariables.put("notHasPermission", new NotHasPermissionDirective(permissionService)); addFreemarkerVariables(freemarkerVariables); result.setFreemarkerVariables(freemarkerVariables); return result; }
Example 3
Source File: ViewResolutionIntegrationTests.java From spring-analysis-note with MIT License | 4 votes |
@Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setTemplateLoaderPath("/WEB-INF/"); return configurer; }
Example 4
Source File: ViewResolutionIntegrationTests.java From spring-analysis-note with MIT License | 4 votes |
@Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setTemplateLoaderPath("/WEB-INF/"); return configurer; }
Example 5
Source File: ViewResolutionIntegrationTests.java From java-technology-stack with MIT License | 4 votes |
@Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setTemplateLoaderPath("/WEB-INF/"); return configurer; }
Example 6
Source File: ViewResolutionIntegrationTests.java From java-technology-stack with MIT License | 4 votes |
@Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setTemplateLoaderPath("/WEB-INF/"); return configurer; }
Example 7
Source File: FreeMarkerViewConfiguration.java From apm-agent-java with Apache License 2.0 | 4 votes |
@Bean public FreeMarkerConfigurer freemarkerConfig() { FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer(); freeMarkerConfigurer.setTemplateLoaderPath("/freemarker"); return freeMarkerConfigurer; }
Example 8
Source File: SpringContextConfig.java From Spring-5.0-Cookbook with MIT License | 4 votes |
@Bean(name = "freemarkerConfig") public FreeMarkerConfigurer getFreemarkerConfig() { FreeMarkerConfigurer config = new FreeMarkerConfigurer(); config.setTemplateLoaderPath("/WEB-INF/templates/"); return config; }
Example 9
Source File: SpringWebReactiveConfig.java From Spring-5.0-Cookbook with MIT License | 4 votes |
@Bean(name = "freemarkerConfig") public FreeMarkerConfigurer getFreemarkerConfig() { FreeMarkerConfigurer config = new FreeMarkerConfigurer(); config.setTemplateLoaderPath("/WEB-INF/templates/"); return config; }
Example 10
Source File: SpringContextConfig.java From Spring-5.0-Cookbook with MIT License | 4 votes |
@Bean(name = "freemarkerConfig") public FreeMarkerConfigurer getFreemarkerConfig() { FreeMarkerConfigurer config = new FreeMarkerConfigurer(); config.setTemplateLoaderPath("/WEB-INF/templates/"); return config; }
Example 11
Source File: ViewResolutionIntegrationTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setTemplateLoaderPath("/WEB-INF/"); return configurer; }
Example 12
Source File: ViewResolutionIntegrationTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setTemplateLoaderPath("/WEB-INF/"); return configurer; }
Example 13
Source File: EmailConfiguration.java From tutorials with MIT License | 4 votes |
@Bean public FreeMarkerConfigurer freemarkerConfig() { FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer(); freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/views/mail"); return freeMarkerConfigurer; }
Example 14
Source File: FreemarkerConfiguration.java From tutorials with MIT License | 4 votes |
@Bean public FreeMarkerConfigurer freemarkerConfig() { FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer(); freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/views/"); return freeMarkerConfigurer; }
Example 15
Source File: SpringWebConfig.java From tutorials with MIT License | 4 votes |
@Bean public FreeMarkerConfigurer freemarkerConfig() { FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer(); freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/views/ftl/"); return freeMarkerConfigurer; }
Example 16
Source File: WebConfig.java From spring4-sandbox with Apache License 2.0 | 4 votes |
@Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setTemplateLoaderPath("/WEB-INF/templates/"); return configurer; }