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

The following examples show how to use org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver#setPrefix() . 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: 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 5
Source File: WebConfig.java    From tutorials with MIT License 5 votes vote down vote up
private ITemplateResolver templateResolver() {
  SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
  resolver.setApplicationContext(applicationContext);
  resolver.setPrefix("/WEB-INF/templates/");
  resolver.setSuffix(".html");
  resolver.setTemplateMode(TemplateMode.HTML);
  return resolver;
}
 
Example 6
Source File: WebConfig.java    From spring-reactive-sample with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public SpringResourceTemplateResolver thymeleafTemplateResolver() {

    final SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setApplicationContext(this.ctx);
    resolver.setPrefix("classpath:/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setCacheable(false);
    resolver.setCheckExistence(false);
    return resolver;

}
 
Example 7
Source File: WebConfig.java    From spring-reactive-sample with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public SpringResourceTemplateResolver thymeleafTemplateResolver() {

    final SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setApplicationContext(this.ctx);
    resolver.setPrefix("classpath:/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setCacheable(false);
    resolver.setCheckExistence(false);
    return resolver;

}
 
Example 8
Source File: WebConfig.java    From spring-reactive-sample with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public SpringResourceTemplateResolver thymeleafTemplateResolver() {

    final SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setApplicationContext(this.ctx);
    resolver.setPrefix("classpath:/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setCacheable(false);
    resolver.setCheckExistence(false);
    return resolver;

}
 
Example 9
Source File: WebConfig.java    From spring-reactive-sample with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public SpringResourceTemplateResolver thymeleafTemplateResolver() {

    final SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setApplicationContext(this.ctx);
    resolver.setPrefix("classpath:/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setCacheable(false);
    resolver.setCheckExistence(false);
    return resolver;

}
 
Example 10
Source File: SpringContextConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean(name ="templateResolver")	
public SpringResourceTemplateResolver getTemplateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
	templateResolver.setPrefix("/WEB-INF/templates/");
	templateResolver.setSuffix(".html");
	templateResolver.setTemplateMode("XHTML");
	return templateResolver;
}
 
Example 11
Source File: SpringWebReactiveConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean(name ="templateResolver")	
 public SpringResourceTemplateResolver getTemplateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
 	templateResolver.setPrefix("/WEB-INF/templates/");
 	templateResolver.setSuffix(".html");
 	templateResolver.setTemplateMode("XHTML");
 	return templateResolver;
 }
 
Example 12
Source File: SpringContextConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean(name ="templateResolver")	
public SpringResourceTemplateResolver getTemplateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
	templateResolver.setPrefix("/WEB-INF/templates/");
	templateResolver.setSuffix(".html");
	templateResolver.setTemplateMode("XHTML");
	return templateResolver;
}
 
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: WebMVCConfig.java    From tutorials with MIT License 5 votes vote down vote up
private ITemplateResolver htmlTemplateResolver() {
    SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setApplicationContext(applicationContext);
    resolver.setPrefix("/WEB-INF/views/");
    resolver.setCacheable(false);
    resolver.setTemplateMode(TemplateMode.HTML);
    return resolver;
}
 
Example 15
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 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: 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 18
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 19
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 20
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;
}