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


Java TemplateResolver.setTemplateMode方法代码示例

本文整理汇总了Java中org.thymeleaf.templateresolver.TemplateResolver.setTemplateMode方法的典型用法代码示例。如果您正苦于以下问题:Java TemplateResolver.setTemplateMode方法的具体用法?Java TemplateResolver.setTemplateMode怎么用?Java TemplateResolver.setTemplateMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.thymeleaf.templateresolver.TemplateResolver的用法示例。


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

示例1: AssetsBundleCustomErrorHandler

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
public AssetsBundleCustomErrorHandler(Environment environment) {
    this.environment = environment;

    TemplateResolver templateResolver = new TemplateResolver();
    String baseDirForTemplates = System.getProperty("baseDirForTemplates");
    if (baseDirForTemplates != null) {
        templateResolver.setResourceResolver(new FileResourceResolver());
        templateResolver.setPrefix(baseDirForTemplates + "/templates/");
    } else {
        templateResolver.setResourceResolver(new ThymeleafResourceResolver());
        templateResolver.setPrefix("/templates/");
    }
    templateResolver.setTemplateMode("HTML5");
    templateResolver.setCacheable(false);
    templateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
    engine = new TemplateEngine();
    engine.setTemplateResolver(templateResolver);
}
 
开发者ID:openregister,项目名称:openregister-java,代码行数:19,代码来源:AssetsBundleCustomErrorHandler.java

示例2: init

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
/**
 * Configures engine and template resolving.
 */
@Override
public void init(@SuppressWarnings("rawtypes") NamedList args) {
   checkNotNull(args);
   this.configuration = SolrParams.toSolrParams(args);

   // configure template resolver
   templateResolver = new TemplateResolver();
   templateResolver.setResourceResolver(resourceResolver);
   templateResolver.setCharacterEncoding("utf-8");
   templateResolver.setTemplateMode(configuration.get("tl.templateMode", "XHTML"));
   templateResolver.setSuffix(configuration.get("tl.suffix", ".html"));

   if (configuration.get("tl.cacheTtlMs") != null) {
      templateResolver.setCacheTTLMs(Long.parseLong(configuration.get("tl.cacheTTLMs")));
   } else {
      templateResolver.setCacheTTLMs(TimeUnit.HOURS.toMillis(1l));
   }

   if (configuration.get("tl.locale") != null) {
      locale = Locale.forLanguageTag(configuration.get("tl.locale"));
   }

   layoutDialect = new LayoutDialect();
}
 
开发者ID:shopping24,项目名称:solr-thymeleaf,代码行数:28,代码来源:ThymeleafResponseWriter.java

示例3: createDefaultTemplateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
private static TemplateResolver createDefaultTemplateResolver(String prefix, String suffix) {
    TemplateResolver defaultTemplateResolver = new TemplateResolver();
    defaultTemplateResolver.setTemplateMode(DEFAULT_TEMPLATE_MODE);

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

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

    //defaultTemplateResolver.setCacheable(false);
    defaultTemplateResolver.setCacheTTLMs(DEFAULT_CACHE_TTL_MS);
    defaultTemplateResolver.setResourceResolver(new FileResourceResolver());
    return defaultTemplateResolver;
}
 
开发者ID:LeonHartley,项目名称:Coerce,代码行数:18,代码来源:ThymeleafViewParser.java

示例4: defaultTemplateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
@Bean
public TemplateResolver defaultTemplateResolver() {
	TemplateResolver resolver = new TemplateResolver();
	resolver.setResourceResolver(thymeleafResourceResolver());
	resolver.setPrefix(this.properties.getPrefix());
	resolver.setSuffix(this.properties.getSuffix());
	resolver.setTemplateMode(this.properties.getMode());
	if (this.properties.getEncoding() != null) {
		resolver.setCharacterEncoding(this.properties.getEncoding().name());
	}
	resolver.setCacheable(this.properties.isCache());
	Integer order = this.properties.getTemplateResolverOrder();
	if (order != null) {
		resolver.setOrder(order);
	}
	return resolver;
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:18,代码来源:ThymeleafAutoConfiguration.java

示例5: createThymeleaf

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
@Bean
public ThymeleafTemplateEngine createThymeleaf() {
    boolean cachingEnabled = env.getProperty("jbakery.thymeleaf.cachingEnabled", Boolean.class, false);

    TemplateResolver templateResolver = new TemplateResolver();
    templateResolver.setResourceResolver(new FileResourceResolver());
    templateResolver.setPrefix("templates/");
    templateResolver.setTemplateMode("HTML5");
    templateResolver.setSuffix(".html");
    templateResolver.setCacheable(cachingEnabled);

    templateResolver.addTemplateAlias("", "/index");
    templateResolver.addTemplateAlias("/", "/index");

    ThymeleafTemplateEngine engine = ThymeleafTemplateEngine.create()
            .setMode(StandardTemplateModeHandlers.HTML5.getTemplateModeName());
    // enable layout
    engine.getThymeleafTemplateEngine().addDialect(new LayoutDialect());
    engine.getThymeleafTemplateEngine().setTemplateResolver(templateResolver);

    return engine;
}
 
开发者ID:netdava,项目名称:jbakery,代码行数:23,代码来源:Config.java

示例6: defaultTemplateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
@Bean
public ITemplateResolver defaultTemplateResolver() {
    final TemplateResolver resolver = new TemplateResolver();
    resolver.setResourceResolver(thymeleafResourceResolver());
    resolver.setPrefix(this.environment.getProperty("prefix", DEFAULT_PREFIX));
    resolver.setSuffix(this.environment.getProperty("suffix", DEFAULT_SUFFIX));
    resolver.setTemplateMode(this.environment.getProperty("mode", "HTML5"));
    resolver.setCharacterEncoding(this.environment.getProperty("encoding", "UTF-8"));

    final Boolean cache = this.environment.getProperty("cache", Boolean.class, true);
    resolver.setCacheable(cache);
    if (!cache) {
        resolver.setCacheTTLMs(0L);
    }

    return resolver;
}
 
开发者ID:mhmxs,项目名称:SpringClips,代码行数:18,代码来源:ThymeleafConfiguration.java

示例7: defaultTemplateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
@Bean
public ITemplateResolver defaultTemplateResolver() {
    TemplateResolver resolver = new FileTemplateResolver();
    resolver.setSuffix(".html");
    resolver.setPrefix("src/main/resources/templates/");
    resolver.setTemplateMode("HTML5");
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCacheable(false);
    return resolver;
}
 
开发者ID:genome-nexus,项目名称:g2s,代码行数:11,代码来源:ThymeleafConfiguration.java

示例8: defaultTemplateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
@Bean
public TemplateResolver defaultTemplateResolver() {
    TemplateResolver resolver = new TemplateResolver();
    resolver.setResourceResolver(thymeleafResourceResolver(rl));
    resolver.setPrefix("classpath:/META-INF/resources/WEB-INF/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode("HTML5");
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCacheable(false);
    return resolver;
}
 
开发者ID:openwms,项目名称:webworms,代码行数:12,代码来源:ThymeleafConfiguration.java

示例9: ThymeleafViewRenderer

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
public ThymeleafViewRenderer(
        String templateMode,
        String prefix,
        String suffix,
        boolean cacheable) {
    super();

    this.suffix = suffix;

    TemplateResolver templateResolver = new TemplateResolver();

    String baseDirForTemplates = System.getProperty("baseDirForTemplates");
    if (baseDirForTemplates != null) {
        templateResolver.setResourceResolver(new FileResourceResolver());
        templateResolver.setPrefix(baseDirForTemplates + prefix);
    } else {
        templateResolver.setResourceResolver(new ThymeleafResourceResolver());
        templateResolver.setPrefix(prefix);
    }

    templateResolver.setTemplateMode(templateMode);
    templateResolver.setCacheable(cacheable);
    templateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
    engine = new TemplateEngine();
    engine.setTemplateResolver(templateResolver);

}
 
开发者ID:openregister,项目名称:openregister-java,代码行数:28,代码来源:ThymeleafViewRenderer.java

示例10: emailTemplateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
private static TemplateResolver emailTemplateResolver() {
  TemplateResolver templateResolver = new ClassLoaderTemplateResolver();
  templateResolver.setPrefix("email/");
  templateResolver.setSuffix(".html");
  templateResolver.setTemplateMode("HTML5");
  templateResolver.setCharacterEncoding("UTF-8");
  templateResolver.setOrder(1);
  templateResolver.setCacheable(false);
  return templateResolver;
}
 
开发者ID:seunlands,项目名称:gest-ecole,代码行数:11,代码来源:GestEcoleWebConfig.java

示例11: createDefaultTemplateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
private static TemplateResolver createDefaultTemplateResolver(String prefix, String suffix) {
  TemplateResolver defaultTemplateResolver = new TemplateResolver();
  defaultTemplateResolver.setTemplateMode(DEFAULT_TEMPLATE_MODE);

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

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

  defaultTemplateResolver.setCacheTTLMs(DEFAULT_CACHE_TTL_MS);
  defaultTemplateResolver.setResourceResolver(new ClassLoaderResourceResolver());
  return defaultTemplateResolver;
}
 
开发者ID:airbnb,项目名称:reair,代码行数:13,代码来源:ThymeleafTemplateEngine.java

示例12: webTemplateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
@Bean
public TemplateResolver webTemplateResolver() {
	TemplateResolver templateResolver = new ServletContextTemplateResolver();
	templateResolver.setPrefix(TEMPLATE_RESOLVER_PREFIX);
	templateResolver.setSuffix(TEMPLATE_RESOLVER_SUFFIX);
	templateResolver.setTemplateMode(TEMPLATE_RESOLVER_TEMPLATE_MODE);
	templateResolver.setCharacterEncoding(TEMPLATE_RESOLVER_CHAR_ENCODING);
	templateResolver.setCacheable(false);
	return templateResolver;
}
 
开发者ID:gsag,项目名称:spring-mvc-seed,代码行数:11,代码来源:WebMvcConfiguration.java

示例13: getMailTemplateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
@Bean
public TemplateResolver getMailTemplateResolver() {
    TemplateResolver resolver = new ClassLoaderTemplateResolver();
    resolver.setPrefix("addon-administration/templates/mail/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode("HTML5");
    resolver.setCharacterEncoding("UTF-8");

    return resolver;
}
 
开发者ID:osiam,项目名称:addon-administration,代码行数:11,代码来源:MailConfig.java

示例14: templateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
@Bean
public TemplateResolver templateResolver() {

    final TemplateResolver resolver = new ServletContextTemplateResolver();
    resolver.setPrefix("/WEB-INF/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode("HTML5");

    return resolver;
}
 
开发者ID:nikola-zivkov,项目名称:example-springmvc-thymeleaf,代码行数:11,代码来源:WebAppConfig.java

示例15: configure

import org.thymeleaf.templateresolver.TemplateResolver; //导入方法依赖的package包/类
/**
 * Initializes the thymeleaf template engine.
 */
@Validate
public synchronized void configure() {
    // Thymeleaf specifics
    String mode = configuration.getWithDefault("application.template.thymeleaf.mode", "HTML5");

    int ttl = configuration.getIntegerWithDefault("application.template.thymeleaf.ttl", 60 * 1000);
    if (configuration.isDev()) {
        // In dev mode, reduce the ttl to the strict minimum so we are sure to have updated template rendering.
        ttl = 1;
    }


    LOGGER.debug("Thymeleaf configuration: mode={}, ttl={}", mode, ttl);

    // A TCCL switch is required here as the default Thymeleaf engine initialization triggers a class loading
    // from a class that may be present in the class path  (org/apache/xerces/xni/parser/XMLParserConfiguration).
    // By setting the TCCL, it fails quietly, if not, it may find it but failed to instantiate it (version
    // mismatch or whatever). As this class is only used to  support the HTML5LEGACY Templates (so not use here),
    // we don't really care.

    final ClassLoader orig = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
        engine = new WisdomTemplateEngine(dialects);
    } finally {
        Thread.currentThread().setContextClassLoader(orig);
    }

    // Initiate the template resolver.
    TemplateResolver resolver = new TemplateResolver();
    resolver.setResourceResolver(new WisdomURLResourceResolver(this));
    resolver.setTemplateMode(mode);
    resolver.setCacheTTLMs((long) ttl);
    engine.setTemplateResolver(resolver);

    engine.setMessageResolver(messageResolver);
    engine.initialize();
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:42,代码来源:ThymeleafTemplateCollector.java


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