Java Code Examples for org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver#setCharacterEncoding()

The following examples show how to use org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver#setCharacterEncoding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
    // 透過此實例進行相關設定,後續用來建立模版引擎物件
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	// 開發階段可設定為不快取模版內容,修改模版才能即時反應變更
	resolver.setCacheable(false);
    // 搭配控制器傳回值的前置名稱
	resolver.setPrefix("/WEB-INF/templates/");
    // 搭配控制器傳回值的後置名稱
	resolver.setSuffix(".html");
	// HTML 頁面編碼
	resolver.setCharacterEncoding("UTF-8");
    // 這是一份 HTML 文件
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 2
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
    // 透過此實例進行相關設定,後續用來建立模版引擎物件
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	// 開發階段可設定為不快取模版內容,修改模版才能即時反應變更
	resolver.setCacheable(false);
    // 搭配控制器傳回值的前置名稱
	resolver.setPrefix("/WEB-INF/templates/");
    // 搭配控制器傳回值的後置名稱
	resolver.setSuffix(".html");
	// HTML 頁面編碼
	resolver.setCharacterEncoding("UTF-8");
    // 這是一份 HTML 文件
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 3
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
    // 透過此實例進行相關設定,後續用來建立模版引擎物件
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	// 開發階段可設定為不快取模版內容,修改模版才能即時反應變更
	resolver.setCacheable(false);
    // 搭配控制器傳回值的前置名稱
	resolver.setPrefix("/WEB-INF/templates/");
    // 搭配控制器傳回值的後置名稱
	resolver.setSuffix(".html");
	// HTML 頁面編碼
	resolver.setCharacterEncoding("UTF-8");
    // 這是一份 HTML 文件
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 4
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
    // 透過此實例進行相關設定,後續用來建立模版引擎物件
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	// 開發階段可設定為不快取模版內容,修改模版才能即時反應變更
	resolver.setCacheable(false);
    // 搭配控制器傳回值的前置名稱
	resolver.setPrefix("/WEB-INF/templates/");
    // 搭配控制器傳回值的後置名稱
	resolver.setSuffix(".html");
	// HTML 頁面編碼
	resolver.setCharacterEncoding("UTF-8");
    // 這是一份 HTML 文件
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 5
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
    // 透過此實例進行相關設定,後續用來建立模版引擎物件
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	// 開發階段可設定為不快取模版內容,修改模版才能即時反應變更
	resolver.setCacheable(false);
    // 搭配控制器傳回值的前置名稱
	resolver.setPrefix("/WEB-INF/templates/");
    // 搭配控制器傳回值的後置名稱
	resolver.setSuffix(".html");
	// HTML 頁面編碼
	resolver.setCharacterEncoding("UTF-8");
    // 這是一份 HTML 文件
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 6
Source File: WebMvcConfig.java    From spring-comparing-template-engines with Apache License 2.0 5 votes vote down vote up
@Bean
public SpringResourceTemplateResolver thymeleafTemplateResolver() {
	SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
	templateResolver.setApplicationContext(this.applicationContext);
	templateResolver.setPrefix("/WEB-INF/thymeleaf/");
	templateResolver.setSuffix(".html");
	templateResolver.setTemplateMode(TemplateMode.HTML);
	templateResolver.setCacheable(false);
	templateResolver.setCharacterEncoding("UTF-8");

	return templateResolver;
}
 
Example 7
Source File: AdminServerNotifierAutoConfiguration.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Bean
public TemplateEngine mailNotifierTemplateEngine() {
    SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setApplicationContext(this.applicationContext);
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setCharacterEncoding(StandardCharsets.UTF_8.name());

    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    templateEngine.addTemplateResolver(resolver);
    return templateEngine;
}
 
Example 8
Source File: AdminServerUiAutoConfiguration.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@Bean
public SpringResourceTemplateResolver adminTemplateResolver() {
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(this.applicationContext);
	resolver.setPrefix(this.adminUi.getTemplateLocation());
	resolver.setSuffix(".html");
	resolver.setTemplateMode(TemplateMode.HTML);
	resolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
	resolver.setCacheable(this.adminUi.isCacheTemplates());
	resolver.setOrder(10);
	resolver.setCheckExistence(true);
	return resolver;
}
 
Example 9
Source File: AdminServerNotifierAutoConfiguration.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@Bean
public TemplateEngine mailNotifierTemplateEngine() {
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(this.applicationContext);
	resolver.setTemplateMode(TemplateMode.HTML);
	resolver.setCharacterEncoding(StandardCharsets.UTF_8.name());

	SpringTemplateEngine templateEngine = new SpringTemplateEngine();
	templateEngine.addTemplateResolver(resolver);
	return templateEngine;
}
 
Example 10
Source File: WallRideMailConfiguration.java    From wallride with Apache License 2.0 5 votes vote down vote up
@Bean(name = "emailTemplateResolver")
	public ITemplateResolver emailTemplateResolver() {
		SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
//		resolver.setResourceResolver(wallRideResourceResourceResolver);
		resolver.setApplicationContext(applicationContext);
		resolver.setPrefix(environment.getRequiredProperty("spring.thymeleaf.prefix.mail"));
		resolver.setSuffix(this.properties.getSuffix());
		resolver.setTemplateMode(this.properties.getMode());
		resolver.setCharacterEncoding(this.properties.getEncoding().name());
		resolver.setCacheable(this.properties.isCache());
		resolver.setOrder(1);
		return resolver;
	}
 
Example 11
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	resolver.setCacheable(false);
	resolver.setPrefix("/WEB-INF/templates/");
	resolver.setSuffix(".html");
	resolver.setCharacterEncoding("UTF-8");
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 12
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	resolver.setCacheable(false);
	resolver.setPrefix("/WEB-INF/templates/");
	resolver.setSuffix(".html");
	resolver.setCharacterEncoding("UTF-8");
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 13
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	resolver.setCacheable(false);
	resolver.setPrefix("/WEB-INF/templates/");
	resolver.setSuffix(".html");
	resolver.setCharacterEncoding("UTF-8");
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 14
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	resolver.setCacheable(false);
	resolver.setPrefix("/WEB-INF/templates/");
	resolver.setSuffix(".html");
	resolver.setCharacterEncoding("UTF-8");
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 15
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	resolver.setCacheable(false);
	resolver.setPrefix("/WEB-INF/templates/");
	resolver.setSuffix(".html");
	resolver.setCharacterEncoding("UTF-8");
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 16
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ITemplateResolver templateResolver() {
	SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
	resolver.setApplicationContext(applicationContext);
	
	resolver.setCacheable(false);
	resolver.setPrefix("/WEB-INF/templates/");
	resolver.setSuffix(".html");
	resolver.setCharacterEncoding("UTF-8");
	resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 17
Source File: ApiBootLoggingAdminUiAutoConfiguration.java    From api-boot with Apache License 2.0 5 votes vote down vote up
/**
 * Config thymeleaf Template Resolver
 *
 * @return SpringResourceTemplateResolver
 */
@Bean
public SpringResourceTemplateResolver adminTemplateResolver() {
    SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setApplicationContext(this.applicationContext);
    resolver.setPrefix(this.adminUiProperties.getTemplateLocation());
    resolver.setSuffix(TEMPLATE_SUFFIX);
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
    resolver.setCacheable(this.adminUiProperties.isCacheTemplates());
    resolver.setOrder(10);
    resolver.setCheckExistence(true);
    return resolver;
}