本文整理匯總了Java中org.thymeleaf.templateresolver.ServletContextTemplateResolver.setCacheTTLMs方法的典型用法代碼示例。如果您正苦於以下問題:Java ServletContextTemplateResolver.setCacheTTLMs方法的具體用法?Java ServletContextTemplateResolver.setCacheTTLMs怎麽用?Java ServletContextTemplateResolver.setCacheTTLMs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.thymeleaf.templateresolver.ServletContextTemplateResolver
的用法示例。
在下文中一共展示了ServletContextTemplateResolver.setCacheTTLMs方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入方法依賴的package包/類
@Override
public void init() {
// Setup ThymeLeaf
ServletContextTemplateResolver templateResolver =
new ServletContextTemplateResolver(this.getServletContext());
templateResolver.setPrefix("/WEB-INF/templates/");
templateResolver.setSuffix(".html");
templateResolver.setCacheTTLMs(Long.valueOf(1200000L)); // TTL=20m
// 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);
}
示例2: get
import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入方法依賴的package包/類
@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;
}
示例3: configure
import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入方法依賴的package包/類
/**
* Configure settings from the struts.xml or struts.properties, using sensible
* defaults if values are not provided.
*/
public void configure() {
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
templateResolver.setTemplateMode(templateMode);
templateResolver.setCharacterEncoding(characterEncoding);
templateResolver.setPrefix(prefix);
templateResolver.setSuffix(suffix);
templateResolver.setCacheable(cacheable);
templateResolver.setCacheTTLMs(cacheTtlMillis);
templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(templateResolver);
templateEngine.setMessageResolver(new StrutsMessageResolver());
}
示例4: thymeleafTemplateResolver
import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入方法依賴的package包/類
@Bean
public ServletContextTemplateResolver thymeleafTemplateResolver() {
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
templateResolver.setPrefix("/WEB-INF/views/");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode("HTML5");
templateResolver.setCharacterEncoding("UTF-8");
// Uncomment these lines in order to use
// cache when resolving templates.
templateResolver.setCacheable(false);
templateResolver.setCacheTTLMs(0L);
// -------------------------------------
return templateResolver;
}