Search in sources :

Example 6 with ServletContextTemplateResolver

use of org.thymeleaf.templateresolver.ServletContextTemplateResolver in project java-docs-samples by GoogleCloudPlatform.

the class GaeInfoServlet method init.

@Override
public void init() {
    // Setup ThymeLeaf
    ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(this.getServletContext());
    templateResolver.setPrefix("/WEB-INF/templates/");
    templateResolver.setSuffix(".html");
    // TTL=20m
    templateResolver.setCacheTTLMs(Long.valueOf(1200000L));
    // Cache is set to true by default. Set to false if you want templates to
    // be automatically updated when modified.
    templateResolver.setCacheable(true);
    templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(templateResolver);
}
Also used : TemplateEngine(org.thymeleaf.TemplateEngine) ServletContextTemplateResolver(org.thymeleaf.templateresolver.ServletContextTemplateResolver)

Example 7 with ServletContextTemplateResolver

use of org.thymeleaf.templateresolver.ServletContextTemplateResolver in project java-docs-samples by GoogleCloudPlatform.

the class GaeInfoServlet method init.

@Override
public void init() {
    // Setup ThymeLeaf
    ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(this.getServletContext());
    templateResolver.setPrefix("/WEB-INF/templates/");
    templateResolver.setSuffix(".html");
    // TTL=20m
    templateResolver.setCacheTTLMs(Long.valueOf(1200000L));
    // Cache is set to true by default. Set to false if you want templates to
    // be automatically updated when modified.
    templateResolver.setCacheable(true);
    templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(templateResolver);
}
Also used : TemplateEngine(org.thymeleaf.TemplateEngine) ServletContextTemplateResolver(org.thymeleaf.templateresolver.ServletContextTemplateResolver)

Example 8 with ServletContextTemplateResolver

use of org.thymeleaf.templateresolver.ServletContextTemplateResolver in project stdlib by petergeneric.

the class TemplateResolverProvider method get.

@Override
public ITemplateResolver get() {
    ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
    resolver.setTemplateMode("HTML5");
    // Load templates from WEB-INF/templates/{name}.html
    resolver.setPrefix("/WEB-INF/template/");
    resolver.setSuffix(".html");
    if (cacheTTL.getMilliseconds() > 0) {
        // cache templates for an hour
        resolver.setCacheTTLMs(cacheTTL.getMilliseconds());
        resolver.setCacheable(true);
    } else {
        // Don't cache
        resolver.setCacheable(false);
    }
    return resolver;
}
Also used : ServletContextTemplateResolver(org.thymeleaf.templateresolver.ServletContextTemplateResolver)

Example 9 with ServletContextTemplateResolver

use of org.thymeleaf.templateresolver.ServletContextTemplateResolver in project tutorials by eugenp.

the class ClientWebConfig method templateResolver.

@Bean
@Description("Thymeleaf template resolver serving HTML 5")
public ServletContextTemplateResolver templateResolver() {
    final ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
    templateResolver.setPrefix("/WEB-INF/templates/");
    templateResolver.setSuffix(".html");
    templateResolver.setTemplateMode("HTML5");
    return templateResolver;
}
Also used : ServletContextTemplateResolver(org.thymeleaf.templateresolver.ServletContextTemplateResolver) Description(org.springframework.context.annotation.Description) Bean(org.springframework.context.annotation.Bean)

Aggregations

ServletContextTemplateResolver (org.thymeleaf.templateresolver.ServletContextTemplateResolver)9 Bean (org.springframework.context.annotation.Bean)4 TemplateEngine (org.thymeleaf.TemplateEngine)4 File (java.io.File)1 Description (org.springframework.context.annotation.Description)1 TemplateResolver (org.thymeleaf.templateresolver.TemplateResolver)1