M
M
Mark Ivanych2016-05-08 09:43:10
Spring
Mark Ivanych, 2016-05-08 09:43:10

Spring, FreeMarker: how to pass your config.properties to the template?

Hello, how to make variable available in html template?

@Value("${param}")
private String param;
@Bean
public FreeMarkerConfigurer freeMarkerConfig() {

    Properties settings = new Properties();
    settings.setProperty("number_format", "0.##");
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    configurer.setDefaultEncoding("UTF-8");
    configurer.setTemplateLoaderPath("/WEB-INF/template");
    settings.setProperty("template_exception_handler", "html_debug");
    configurer.setFreemarkerSettings(settings);

    return configurer;
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question