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


Java ITemplateResolver类代码示例

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


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

示例1: mailPreviewTemplateResolver

import org.thymeleaf.templateresolver.ITemplateResolver; //导入依赖的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.templateresolver.ITemplateResolver; //导入依赖的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: supports

import org.thymeleaf.templateresolver.ITemplateResolver; //导入依赖的package包/类
protected boolean supports(TemplateEngineModel data) {
    if (!configured) {
        return false;
    }
    String contentType = getContentTypeFromModel(data.getInlineContentItem());
    if (contentType == null) {
        return false;
    }
    Set<ITemplateResolver> templateResolvers = templateEngine.getTemplateResolvers();
    for (ITemplateResolver resolver : templateResolvers) {
        if (resolver instanceof AbstractTemplateResolver) {
            TemplateResolution templateResolution = resolver.resolveTemplate(templateEngine.getConfiguration(), null, contentType, null);
            if (templateResolution != null && templateResolution.getTemplateResource().exists()) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:Kentico,项目名称:delivery-sdk-java,代码行数:20,代码来源:ThymeleafTemplateEngine.java

示例4: webTemplateResolver

import org.thymeleaf.templateresolver.ITemplateResolver; //导入依赖的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: xmlTemplateResolver

import org.thymeleaf.templateresolver.ITemplateResolver; //导入依赖的package包/类
@Bean
	public ITemplateResolver xmlTemplateResolver() {
//		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/");
		Set<String> patterns = new HashSet<>();
		patterns.add("/xml/*"); // Start with "xml"
		resolver.setResolvablePatterns(patterns);
		resolver.setSuffix(".xml");
		resolver.setCharacterEncoding("UTF-8");
		// NB, selecting HTML5 as the template mode.
		resolver.setTemplateMode("XML");
		resolver.setCacheable(config.isProductionEnvironment());
		// resolver.setOrder(30); // Order not needed because resolver on different ViewResolver
		return resolver;
	}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:20,代码来源:YadaWebConfig.java

示例6: overrideCharacterEncoding

import org.thymeleaf.templateresolver.ITemplateResolver; //导入依赖的package包/类
@Test
public void overrideCharacterEncoding() throws Exception {
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.thymeleaf.encoding:UTF-16");
	this.context.register(ThymeleafAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	this.context.getBean(TemplateEngine.class).initialize();
	ITemplateResolver resolver = this.context.getBean(ITemplateResolver.class);
	assertThat(resolver instanceof TemplateResolver).isTrue();
	assertThat(((TemplateResolver) resolver).getCharacterEncoding())
			.isEqualTo("UTF-16");
	ThymeleafViewResolver views = this.context.getBean(ThymeleafViewResolver.class);
	assertThat(views.getCharacterEncoding()).isEqualTo("UTF-16");
	assertThat(views.getContentType()).isEqualTo("text/html;charset=UTF-16");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:ThymeleafAutoConfigurationTests.java

示例7: getTemplateEngine

import org.thymeleaf.templateresolver.ITemplateResolver; //导入依赖的package包/类
/**
 * Producer method building and configuring the {@link TemplateEngine} instance to be used in the application. The
 * engine's template resolver is set up to follow MVC requirements. JAX-RS parameter conversion bridges are
 * detected, and if one is present, the engine is set up to use it.
 *
 * Subclasses can override and {@link javax.enterprise.inject.Specializes specialize} this method to add additional
 * configuration (e.g. call {@link TemplateEngine#addDialect(org.thymeleaf.dialect.IDialect)} to add a dialect).
 *
 * @return the newly created and configured {@link TemplateEngine} instance
 */
@Produces public TemplateEngine getTemplateEngine() {
    final TemplateEngine engine = new TemplateEngine();
    final ITemplateResolver tr = new MVCTemplateResolver(servletContext, mvcContext);
    engine.setTemplateResolver(tr);
    try {
        final Class<?> pcbClass = Class.forName("hu.inbuss.thymeleaf.jaxrs.ParamConverterBridge");
        final Bean<?> pcbBean = beanManager.resolve(beanManager.getBeans(pcbClass));
        final CreationalContext pcbContext = beanManager.createCreationalContext(pcbBean);
        final ParamConverterBridge pcb = (ParamConverterBridge) beanManager.getReference(pcbBean, pcbClass, pcbContext);
        pcb.installInto(engine);
    } catch (final ClassNotFoundException cnfe) {
        // the Jersey integration module is not present, do nothing
    }
    return engine;
}
 
开发者ID:inbuss,项目名称:thymeleaf-mvc,代码行数:26,代码来源:TemplateEngineProducer.java

示例8: resolveTemplate

import org.thymeleaf.templateresolver.ITemplateResolver; //导入依赖的package包/类
@Override
public TemplateResolution resolveTemplate(TemplateProcessingParameters templateProcessingParameters) {
	String unresolvedTemplateName = templateProcessingParameters.getTemplateName();
	ResourceResolver supportingResolver = resolver.getSupportingResolver(unresolvedTemplateName);
	ITemplateResolver templateResolver;
	try {
		templateResolver = resolverAdapter.adapt(supportingResolver);
		if (forceInitialize) {
			// we must initialize the new templateResolver
			templateResolver.initialize();
		}
		String resolvedPath = supportingResolver.getResourcePath(unresolvedTemplateName).getResolvedPath();
		TemplateProcessingParameters resolvedTemplateProcessingParameters = new TemplateProcessingParameters(templateProcessingParameters.getConfiguration(), resolvedPath,
				templateProcessingParameters.getContext());
		return templateResolver.resolveTemplate(resolvedTemplateProcessingParameters);
	} catch (NoResolverAdapterException e) {
		throw new ResolverAdapterNotFoundException("Unable to resolver template cause no adapter supporting template name '" + unresolvedTemplateName + "' was found. ", e);

	}

}
 
开发者ID:groupe-sii,项目名称:ogham,代码行数:22,代码来源:ThymeLeafFirstSupportingTemplateResolver.java

示例9: testEngine

import org.thymeleaf.templateresolver.ITemplateResolver; //导入依赖的package包/类
@Bean
@DependsOn("propertyConfigurer")
public ThymeleafTestEngine testEngine() {
	ThymeleafTestEngine engine = new ThymeleafTestEngine();

	engine.setCacheManager(thymeleafCacheManager());
	engine.setTemplateModeHandlers(templateModeHandlers());
	engine.setAdditionalDialects(additionalDialects());

	
	
	Set<ITemplateResolver> templateResolvers = new HashSet<ITemplateResolver>();
	templateResolvers.add(servletContextTemplateResolver());
	templateResolvers.add(fileTemplateResolver());
	engine.setTemplateResolvers(templateResolvers);
	
	engine.setServletContext(servletContext);
	engine.setApplicationContext(applicationContext);
	return engine;
}
 
开发者ID:connect-group,项目名称:thymeleaf-tdd,代码行数:21,代码来源:ThymesheetConfig.java

示例10: defaultTemplateResolver

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

示例11: get

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

示例12: templateResolver

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

示例13: templateResolver

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

示例14: htmlTemplateResolver

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

示例15: createDefaultTemplateResolver

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


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