本文整理汇总了Java中org.thymeleaf.templateresolver.ClassLoaderTemplateResolver.setResolvablePatterns方法的典型用法代码示例。如果您正苦于以下问题:Java ClassLoaderTemplateResolver.setResolvablePatterns方法的具体用法?Java ClassLoaderTemplateResolver.setResolvablePatterns怎么用?Java ClassLoaderTemplateResolver.setResolvablePatterns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
的用法示例。
在下文中一共展示了ClassLoaderTemplateResolver.setResolvablePatterns方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: yadaTemplateResolver
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //导入方法依赖的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;
}
示例2: templateEngine
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //导入方法依赖的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;
}
示例3: emailTemplateResolver
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //导入方法依赖的package包/类
public ClassLoaderTemplateResolver emailTemplateResolver() {
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.EMAIL_TEMPLATES_PREFIX); // Attenzione allo slash finale!
// resolver.setPrefix(YadaConstants.EMAIL_TEMPLATES_PREFIX + "/"); // Attenzione allo slash finale!
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(40); // Order not needed because resolver on different SpringTemplateEngine
return resolver;
}
示例4: textTemplateResolver
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //导入方法依赖的package包/类
private ITemplateResolver textTemplateResolver() {
final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setOrder(1);
templateResolver.setResolvablePatterns(Collections.singleton("text/*"));
templateResolver.setPrefix("/mail/");
templateResolver.setSuffix(".txt");
templateResolver.setTemplateMode(TemplateMode.TEXT);
templateResolver.setCharacterEncoding("UTF-8");
templateResolver.setCacheable(false);
return templateResolver;
}
示例5: htmlTemplateResolver
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; //导入方法依赖的package包/类
private ITemplateResolver htmlTemplateResolver() {
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);
return templateResolver;
}