當前位置: 首頁>>代碼示例>>Java>>正文


Java ServletContextTemplateResolver.setCacheTTLMs方法代碼示例

本文整理匯總了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);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:18,代碼來源:GaeInfoServlet.java

示例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;
}
 
開發者ID:petergeneric,項目名稱:stdlib,代碼行數:26,代碼來源:TemplateResolverProvider.java

示例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());
}
 
開發者ID:codework,項目名稱:struts2-thymeleaf-plugin,代碼行數:18,代碼來源:DefaultTemplateEngineProvider.java

示例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;
}
 
開發者ID:fernaspiazu,項目名稱:recruiting-old-style,代碼行數:15,代碼來源:WebApplicationConfig.java


注:本文中的org.thymeleaf.templateresolver.ServletContextTemplateResolver.setCacheTTLMs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。