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


Java ClassLoaderTemplateResolver.setCacheTTLMs方法代碼示例

本文整理匯總了Java中org.thymeleaf.templateresolver.ClassLoaderTemplateResolver.setCacheTTLMs方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassLoaderTemplateResolver.setCacheTTLMs方法的具體用法?Java ClassLoaderTemplateResolver.setCacheTTLMs怎麽用?Java ClassLoaderTemplateResolver.setCacheTTLMs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.thymeleaf.templateresolver.ClassLoaderTemplateResolver的用法示例。


在下文中一共展示了ClassLoaderTemplateResolver.setCacheTTLMs方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testTemplate

import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //導入方法依賴的package包/類
@Test
public void testTemplate() throws Exception {
    ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
    templateResolver.setPrefix("org/restlet/ext/thymeleaf/");
    templateResolver.setSuffix(".html");
    templateResolver.setCacheTTLMs(3600000L);

    final Map<String, Object> map = new TreeMap<>();
    map.put("welcome", "Hello, world");

    final String result = new TemplateRepresentation("test",
            TemplateRepresentation.createTemplateEngine(templateResolver),
            Locale.getDefault(), map, MediaType.TEXT_PLAIN).getText();

    assertTrue(result.contains("Hello, world"));
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:17,代碼來源:ThymeleafTestCase.java

示例2: testThymeleafTemplate

import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //導入方法依賴的package包/類
@Test
@Ignore
public void testThymeleafTemplate() throws IOException, MessagingException {

    ClassLoaderTemplateResolver templateResolver =
            new ClassLoaderTemplateResolver();

    templateResolver.setTemplateMode(TemplateMode.HTML);
    templateResolver.setPrefix("/templates/");
    templateResolver.setSuffix(".html");
    templateResolver.setCacheTTLMs(Long.valueOf(3600000L));

    templateResolver.setCharacterEncoding("UTF-8");
    templateResolver.setCacheable(true);

    TemplateEngine templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(templateResolver);

    Context ctx = new Context();
    ctx.setLocale(Locale.ENGLISH);
    ctx.setVariable("username", "ricky");
    ctx.setVariable("url", "http://www.thymeleaf.org");
    ctx.setVariable("email", "[email protected]");

    StringWriter sw = new StringWriter(1024);
    templateEngine.process("registry", ctx, sw);

    String output = sw.toString();
    System.out.println(output);

    Mail mail = Mail.newBuilder().from(from,"ricky fung")
            .to(to)
            .subject("測試郵件[模板郵件-Thymeleaf]")
            .html(output)
            .build();

    client.send(mail);
}
 
開發者ID:TFdream,項目名稱:okmail,代碼行數:39,代碼來源:OkMailClientTest.java

示例3: testApp

import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //導入方法依賴的package包/類
@Test
@Ignore
public void testApp() throws IOException {

    //use thymeleaf
    ClassLoaderTemplateResolver templateResolver =
            new ClassLoaderTemplateResolver();

    templateResolver.setTemplateMode(TemplateMode.HTML);
    templateResolver.setPrefix("/templates/");
    templateResolver.setSuffix(".html");
    templateResolver.setCacheTTLMs(Long.valueOf(3600000L));

    templateResolver.setCharacterEncoding("UTF-8");
    templateResolver.setCacheable(true);

    TemplateEngine templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(templateResolver);

    Context ctx = new Context();
    ctx.setLocale(Locale.ENGLISH);
    ctx.setVariable("username", "ricky");
    ctx.setVariable("url", "http://www.thymeleaf.org");
    ctx.setVariable("email", "[email protected]");

    StringWriter sw = new StringWriter(1024);
    templateEngine.process("registry", ctx, sw);

    String output = sw.toString();
    System.out.println(output);
}
 
開發者ID:TFdream,項目名稱:okmail,代碼行數:32,代碼來源:ThymeleafTest.java

示例4: createDefaultTemplateResolver

import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //導入方法依賴的package包/類
private static ITemplateResolver createDefaultTemplateResolver(String prefix, String suffix) {
	final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
	templateResolver.setTemplateMode(TemplateMode.HTML);

	templateResolver.setPrefix(
			prefix != null ? prefix : DEFAULT_PREFIX
	);

	templateResolver.setSuffix(
			suffix != null ? suffix : DEFAULT_SUFFIX
	);

	templateResolver.setCacheTTLMs(DEFAULT_CACHE_TTL_MS);
	return templateResolver;
}
 
開發者ID:NovaFox161,項目名稱:DisCal-Discord-Bot,代碼行數:16,代碼來源:ThymeleafTemplateEngine.java

示例5: createTemplateResolver

import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //導入方法依賴的package包/類
/**
 * Returns a new instance of {@link ITemplateResolver} with default
 * configuration (XHTML template model, templates located inside
 * "/WEB-INF/templates/", suffixed by ".html".
 *
 * @return A new instance of {@link ITemplateResolver}.
 */
public static ITemplateResolver createTemplateResolver() {
    ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
    // XHTML is the default mode, but we will set it anyway for better
    // understanding of code
    templateResolver.setTemplateMode("XHTML");
    // This will convert "home" to "/WEB-INF/templates/home.html"
    templateResolver.setPrefix("/WEB-INF/templates/");
    templateResolver.setSuffix(".html");
    // Set template cache TTL to 1 hour. If not set, entries would live in
    // cache until expelled by LRU
    templateResolver.setCacheTTLMs(3600000L);

    return templateResolver;
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:22,代碼來源:TemplateRepresentation.java

示例6: ThymeleafTemplateProcessorImpl

import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //導入方法依賴的package包/類
@Inject
public ThymeleafTemplateProcessorImpl() {
  final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
  templateResolver.setTemplateMode(HTML);
  templateResolver.setSuffix(".html");
  templateResolver.setCacheTTLMs(3600000L);
  this.templateEngine = new TemplateEngine();
  this.templateEngine.setTemplateResolver(templateResolver);
}
 
開發者ID:codenvy,項目名稱:codenvy,代碼行數:10,代碼來源:ThymeleafTemplateProcessorImpl.java

示例7: createDefaultTemplateResolver

import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //導入方法依賴的package包/類
private static ITemplateResolver createDefaultTemplateResolver(String prefix, String suffix) {
    final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
    templateResolver.setTemplateMode(TemplateMode.HTML);

    templateResolver.setPrefix(
            prefix != null ? prefix : DEFAULT_PREFIX
    );

    templateResolver.setSuffix(
            suffix != null ? suffix : DEFAULT_SUFFIX
    );

    templateResolver.setCacheTTLMs(DEFAULT_CACHE_TTL_MS);
    return templateResolver;
}
 
開發者ID:perwendel,項目名稱:spark-template-engines,代碼行數:16,代碼來源:ThymeleafTemplateEngine.java

示例8: createEngine

import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //導入方法依賴的package包/類
private static TemplateEngine createEngine()
{
	ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();

	resolver.setTemplateMode("HTML5");

	resolver.setCacheTTLMs(60 * 1000L);
	resolver.setCacheable(true);

	TemplateEngine engine = new TemplateEngine();
	engine.setTemplateResolver(resolver);

	return engine;
}
 
開發者ID:petergeneric,項目名稱:stdlib,代碼行數:15,代碼來源:GuiceCoreTemplater.java


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