本文整理汇总了Java中org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver.setCharacterEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java SpringResourceTemplateResolver.setCharacterEncoding方法的具体用法?Java SpringResourceTemplateResolver.setCharacterEncoding怎么用?Java SpringResourceTemplateResolver.setCharacterEncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver
的用法示例。
在下文中一共展示了SpringResourceTemplateResolver.setCharacterEncoding方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mailPreviewTemplateResolver
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; //导入方法依赖的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;
}
示例2: webTemplateResolver
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; //导入方法依赖的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;
}
示例3: xmlTemplateResolver
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; //导入方法依赖的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;
}
示例4: defaultTemplateResolver
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; //导入方法依赖的package包/类
@Bean
public SpringResourceTemplateResolver defaultTemplateResolver() {
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
resolver.setApplicationContext(this.applicationContext);
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:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:AbstractTemplateResolverConfiguration.java
示例5: springHtmlResourceTemplateResolver
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; //导入方法依赖的package包/类
@Bean
public SpringResourceTemplateResolver springHtmlResourceTemplateResolver() {
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
resolver.setApplicationContext(this.applicationContext);
resolver.setPrefix(DEFAULT_PREFIX);
resolver.setSuffix(DEFAULT_SUFFIX);
resolver.setTemplateMode(TemplateMode.HTML);
resolver.setCharacterEncoding("UTF-8");
resolver.setCacheable(true);
resolver.setOrder(1);
return resolver;
}
示例6: springTxtResourceTemplateResolver
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; //导入方法依赖的package包/类
@Bean
public SpringResourceTemplateResolver springTxtResourceTemplateResolver() {
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
resolver.setApplicationContext(this.applicationContext);
resolver.setPrefix("classpath:/templates/text/");
resolver.setSuffix(".txt");
resolver.setTemplateMode(TemplateMode.TEXT);
resolver.setCharacterEncoding("UTF-8");
resolver.setCacheable(true);
resolver.setOrder(2);
return resolver;
}
示例7: templateResolver
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; //导入方法依赖的package包/类
@Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
resolver.setPrefix("/WEB-INF/templates/");
resolver.setSuffix(".html");
resolver.setTemplateMode(TemplateMode.HTML);
resolver.setCharacterEncoding("UTF-8");
return resolver;
}
示例8: templateResolver
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; //导入方法依赖的package包/类
@Bean
public ITemplateResolver templateResolver() {
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
resolver.setPrefix(VIEWS);
resolver.setSuffix(".html");
resolver.setTemplateMode(TemplateMode.HTML);
resolver.setCharacterEncoding("UTF-8");
resolver.setCacheable(false);
return resolver;
}