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


Java TemplateResolver.setResourceResolver方法代碼示例

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


在下文中一共展示了TemplateResolver.setResourceResolver方法的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: getFileSystemResolver

import org.thymeleaf.templateresolver.TemplateResolver; //導入方法依賴的package包/類
@Bean
public TemplateResolver getFileSystemResolver() {
    TemplateResolver resolver = new TemplateResolver();
    resolver.setPrefix("");
    resolver.setSuffix("");
    resolver.setCacheable(false);
    resolver.setOrder(1);
    resolver.setResourceResolver(new FileResourceResolver());
    return resolver;
}
 
開發者ID:kamax-io,項目名稱:mxisd,代碼行數:11,代碼來源:ThymeleafConfig.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: 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

示例11: init

import org.thymeleaf.templateresolver.TemplateResolver; //導入方法依賴的package包/類
private void init() {
	siteFolder = new File(BuilderFolders.SITE);
	siteFolder.mkdirs();
	TemplateResolver templateResolver = new TemplateResolver();
	templateResolver.setResourceResolver(new ProjectResourceResolver());
	templateResolver.setSuffix(".html");
	templateEngine = new TemplateEngine();
	templateEngine.setTemplateResolver(templateResolver);
	templateEngine.initialize();
}
 
開發者ID:javabuild,項目名稱:builder-parent,代碼行數:11,代碼來源:ThymeleafPagesGenerator.java

示例12: 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

示例13: defaultTemplateResolver

import org.thymeleaf.templateresolver.TemplateResolver; //導入方法依賴的package包/類
@Bean
public TemplateResolver defaultTemplateResolver() {
	TemplateResolver resolver = new TemplateResolver();
	resolver.setCacheable(false);
	resolver.setResourceResolver(resourceResolver());
	resolver.setTemplateMode(StandardTemplateModeHandlers.HTML5.getTemplateModeName());
	resolver.setCharacterEncoding("UTF-8");
	resolver.setSuffix(".html");
	return resolver;
}
 
開發者ID:resource4j,項目名稱:resource4j,代碼行數:11,代碼來源:ThymeleafResourceConfiguration.java

示例14: CustomThymeleafTemplateEngineImpl

import org.thymeleaf.templateresolver.TemplateResolver; //導入方法依賴的package包/類
public CustomThymeleafTemplateEngineImpl() {
	templateResolver = new TemplateResolver();
	templateResolver.setTemplateMode(ThymeleafTemplateEngine.DEFAULT_TEMPLATE_MODE);
	templateResolver.setResourceResolver(resolver);
	engine.setTemplateResolver(templateResolver);
}
 
開發者ID:quebic-source,項目名稱:puppy-io,代碼行數:7,代碼來源:CustomThymeleafTemplateEngineImpl.java

示例15: onActivate

import org.thymeleaf.templateresolver.TemplateResolver; //導入方法依賴的package包/類
@Override
public void onActivate( Application application )
    throws ActivationException
{
    // Load configuration
    Config config = application.config().atKey( "thymeleaf" );
    String templateMode = config.string( "template_mode" );
    String characterEncoding = config.has( "charset" )
                               ? config.string( "charset" ).toUpperCase( US )
                               : application.defaultCharset().name();
    String prefix = withTrail( withoutHead( config.string( "base_path" ), "/" ), "/" );
    String suffix = config.has( "suffix" )
                    ? config.string( "suffix" )
                    : EMPTY;

    // Setup named templates resolver
    TemplateResolver namedResolver = new TemplateResolver();
    namedResolver.setTemplateMode( templateMode );
    namedResolver.setCharacterEncoding( characterEncoding );
    namedResolver.setPrefix( prefix );
    namedResolver.setSuffix( suffix );
    if( application.mode() == DEV )
    {
        namedResolver.setCacheable( false );
    }
    else if( config.has( "cache_ttl" ) )
    {
        namedResolver.setCacheTTLMs( config.milliseconds( "cache_ttl" ) );
    }
    namedResolver.setResourceResolver( new NamedResourceResolver( application.classLoader() ) );

    // Setup string templates resolver
    TemplateResolver stringResolver = new TemplateResolver();
    stringResolver.setTemplateMode( templateMode );
    stringResolver.setCharacterEncoding( characterEncoding );
    stringResolver.setCacheable( false );
    StringResourceResolver stringResourceResolver = new StringResourceResolver();
    stringResolver.setResourceResolver( stringResourceResolver );

    // Create Thymeleaf Engine
    TemplateEngine thymeleaf = new TemplateEngine();
    thymeleaf.addTemplateResolver( namedResolver );
    thymeleaf.addTemplateResolver( stringResolver );

    // Done!
    templates = new ThymeleafTemplates(
        thymeleaf,
        stringResourceResolver,
        application.config().bool( "thymeleaf.metrics" )
        ? new TemplatesMetricsHandler.Impl( application.plugin( Metrics.class ).metrics(), "thymeleaf" )
        : TemplatesMetricsHandler.NOOP
    );
}
 
開發者ID:werval,項目名稱:werval,代碼行數:54,代碼來源:ThymeleafPlugin.java


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