当前位置: 首页>>代码示例>>Java>>正文


Java TemplateMode类代码示例

本文整理汇总了Java中org.thymeleaf.templatemode.TemplateMode的典型用法代码示例。如果您正苦于以下问题:Java TemplateMode类的具体用法?Java TemplateMode怎么用?Java TemplateMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TemplateMode类属于org.thymeleaf.templatemode包,在下文中一共展示了TemplateMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mailPreviewTemplateResolver

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
/**
	 * Template resolver for mail preview pages that include email templates (maybe I could just use emailTemplateResolver())
	 * @return
	 */
	public ITemplateResolver mailPreviewTemplateResolver() {
//		ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
		SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	    resolver.setApplicationContext(applicationContext);
		resolver.setPrefix("/WEB-INF/classes/" + YadaConstants.EMAIL_TEMPLATES_PREFIX);
// The final slash is not needed because all email template paths must start with "/email/" as specified in the "patterns.add()" statement below
//		resolver.setPrefix("/WEB-INF/classes/" + YadaConstants.EMAIL_TEMPLATES_PREFIX + "/");
		/* From the tutorial:
		 When several template resolvers are applied, it is recommended to specify patterns 
		 for each template resolver so that Thymeleaf can quickly discard those template resolvers 
		 that are not meant to resolve the template, enhancing performance. Doing this is not a 
		 requirement, but a recommendation
		 */
		Set<String> patterns = new HashSet<>();
		patterns.add("/email/*"); // Start with "/email/"
		resolver.setResolvablePatterns(patterns);
		resolver.setSuffix(".html");
		resolver.setCharacterEncoding("UTF-8");
		resolver.setTemplateMode(TemplateMode.HTML);
		resolver.setCacheable(config.isProductionEnvironment());
		resolver.setOrder(20);
		return resolver;
	}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:28,代码来源:YadaWebConfig.java

示例2: configure

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
protected void configure() {
    if (viewResolverConfiguration != null) {
        org.thymeleaf.TemplateEngine engine = new org.thymeleaf.TemplateEngine();
        Set<ITemplateResolver> resolvers = new HashSet<>();
        for (String prefix : viewResolverConfiguration.getPrefixes()) {
            ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
            templateResolver.setPrefix(prefix);
            templateResolver.setSuffix(viewResolverConfiguration.getSuffix());
            templateResolver.setTemplateMode(TemplateMode.HTML);
            templateResolver.setCheckExistence(true);
            resolvers.add(templateResolver);
        }
        engine.setTemplateResolvers(configureTemplateResolvers(resolvers));
        this.templateEngine = engine;
        configured = true;
    }
}
 
开发者ID:Kentico,项目名称:delivery-sdk-java,代码行数:18,代码来源:ThymeleafTemplateEngine.java

示例3: yadaTemplateResolver

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
@Bean
	public ClassLoaderTemplateResolver yadaTemplateResolver() {
		ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
		// Relative paths never work, with or without trailing slash, so better to be consistent without and always use "absolute" paths [xtian]
		resolver.setPrefix(YadaConstants.YADA_VIEW_PREFIX); // Attenzione allo slash finale!
//		resolver.setPrefix(YadaConstants.YADA_VIEW_PREFIX + "/"); // Attenzione allo slash finale!
		/* From the tutorial:
		 When several template resolvers are applied, it is recommended to specify patterns 
		 for each template resolver so that Thymeleaf can quickly discard those template resolvers 
		 that are not meant to resolve the template, enhancing performance. Doing this is not a 
		 requirement, but a recommendation
		 */
		Set<String> patterns = new HashSet<>();
		patterns.add("/yada/*"); // Start with "yada"
		resolver.setResolvablePatterns(patterns);
		resolver.setSuffix(".html");
		resolver.setCharacterEncoding("UTF-8");
		resolver.setTemplateMode(TemplateMode.HTML);
		resolver.setCacheable(config.isProductionEnvironment());
		resolver.setOrder(10); 
		return resolver;
	}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:23,代码来源:YadaWebConfig.java

示例4: webTemplateResolver

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
@Bean
	public ITemplateResolver webTemplateResolver() {
//		ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
		SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	    resolver.setApplicationContext(applicationContext);
		// Relative paths never work, with or without trailing slash, so better to be consistent without and always use "absolute" paths [xtian]
		resolver.setPrefix("/WEB-INF/views");
//		resolver.setPrefix("/WEB-INF/views/");
		resolver.setSuffix(".html");
//		Set<String> patterns = new HashSet<>();
//		patterns.add("^(?!/yada/).*"); // Do not start with "yada" - DOES NOT WORK because it doesn't accept a regexp
//		resolver.setResolvablePatterns(patterns);
		resolver.setCharacterEncoding("UTF-8");
		// NB, selecting HTML5 as the template mode.
		resolver.setTemplateMode(TemplateMode.HTML);
		resolver.setCacheable(config.isProductionEnvironment());
		resolver.setOrder(30); // The last one, because it doesn't have any ResolvablePatterns
		return resolver;
	}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:20,代码来源:YadaWebConfig.java

示例5: templateEngine

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
@Bean
  public SpringTemplateEngine templateEngine() {
  	SpringTemplateEngine mock = spy(SpringTemplateEngine.class);
  	
  	final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setOrder(2);
templateResolver.setResolvablePatterns(Collections.singleton("html/*"));
templateResolver.setPrefix("/mail/");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode(TemplateMode.HTML);
templateResolver.setCharacterEncoding("UTF-8");
templateResolver.setCacheable(false);
  	mock.addTemplateResolver(templateResolver);
  	
  	final ClassLoaderTemplateResolver templateResolverTxt = new ClassLoaderTemplateResolver();
templateResolverTxt.setOrder(1);
templateResolverTxt.setResolvablePatterns(Collections.singleton("text/*"));
templateResolverTxt.setPrefix("/mail/");
templateResolverTxt.setSuffix(".txt");
templateResolverTxt.setTemplateMode(TemplateMode.TEXT);
templateResolverTxt.setCharacterEncoding("UTF-8");
templateResolverTxt.setCacheable(false);
mock.addTemplateResolver(templateResolverTxt);
  	
return mock;
  }
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:27,代码来源:SpringMailTestConfiguration.java

示例6: activate

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
@Activate
protected void activate(ComponentContext componentContext) {
    BundleTemplateResolver templateResolver = new BundleTemplateResolver(componentContext.getUsingBundle());
    templateResolver.setPrefix("views/");
    templateResolver.setSuffix(".html");
    templateResolver.setCharacterEncoding("UTF-8");
    templateResolver.setTemplateMode(TemplateMode.HTML);
    // default is cacheable
    templateResolver.setCacheable(false);
    templateResolver.setOrder(1);
    // RK: This is performance intensive OP, need to look into code for a
    // better alternative
    templateResolver.setCheckExistence(true);
    TemplateEngine engine = new TemplateEngine();
    engine.addTemplateResolver(templateResolver);
}
 
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:17,代码来源:ThymeleafViewEngine.java

示例7: configure

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
@Override
public void configure(final Env env, final Config conf, final Binder binder) throws Throwable {
  ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
  boolean cacheable = !env.name().equals("dev");
  /** Defaults: */
  resolver.setCacheable(cacheable);
  resolver.setPrefix(prefix);
  resolver.setSuffix(suffix);
  resolver.setTemplateMode(TemplateMode.HTML);

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

  if (callback != null) {
    callback.accept(engine, conf);
  }

  binder.bind(TemplateEngine.class).toInstance(engine);
  binder.bind(ITemplateEngine.class).toInstance(engine);

  Multibinder.newSetBinder(binder, Renderer.class)
      .addBinding()
      .toInstance(new ThlEngine(engine, env));
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:25,代码来源:Thl.java

示例8: thymeleafTemplateResolver

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
@Bean
public SpringResourceTemplateResolver thymeleafTemplateResolver() {

    final SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setApplicationContext(this.ctx);
    resolver.setPrefix("classpath:/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setCacheable(false);
    resolver.setCheckExistence(false);
    return resolver;

}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:14,代码来源:WebConfig.java

示例9: testThymeleafTemplate

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的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

示例10: testApp

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的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

示例11: templateResolver

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
@Bean
ITemplateResolver templateResolver()
{
    SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setPrefix("/WEB-INF/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode(TemplateMode.HTML);
    //debug
    resolver.setCacheable(false);
    return resolver;
}
 
开发者ID:scrumtracker,项目名称:scrumtracker2017,代码行数:12,代码来源:ThymeleafConfig.java

示例12: templateResolver

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
private ITemplateResolver templateResolver() {
    SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setApplicationContext(applicationContext);
    resolver.setSuffix(".html");
    resolver.setPrefix("/WEB-INF/templates/");
    resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
开发者ID:ArturWisniewski,项目名称:ToDoApp-Spring,代码行数:9,代码来源:ThymeleafConfig.java

示例13: htmlTemplateResolver

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
private ITemplateResolver htmlTemplateResolver() {
	final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
	templateResolver.setPrefix("/templates/mail/");
	templateResolver.setSuffix(".html");
	templateResolver.setTemplateMode(TemplateMode.HTML);
	templateResolver.setCacheable(false);
	return templateResolver;
}
 
开发者ID:mychalvlcek,项目名称:spring-rest-skeleton,代码行数:9,代码来源:EmailConfiguration.java

示例14: createDefaultTemplateResolver

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的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

示例15: templateResolver

import org.thymeleaf.templatemode.TemplateMode; //导入依赖的package包/类
@Bean
public ITemplateResolver templateResolver() {
    SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setApplicationContext(applicationContext);
    resolver.setPrefix("classpath:/templates");
    resolver.setTemplateMode(TemplateMode.TEXT);
    return resolver;
}
 
开发者ID:linkedin,项目名称:custom-gradle-plugin-portal,代码行数:9,代码来源:ResourceConfig.java


注:本文中的org.thymeleaf.templatemode.TemplateMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。