Skip to content

Instantly share code, notes, and snippets.

@keesun
Created April 27, 2012 11:13
Show Gist options
  • Save keesun/2508457 to your computer and use it in GitHub Desktop.
Save keesun/2508457 to your computer and use it in GitHub Desktop.
adding thymeleaf to spring
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Cantabille</title>
</head>
<body>
Init Cantabille
</body>
</html>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring3</artifactId>
<version>2.0.5</version>
<scope>compile</scope>
</dependency>
// ****************************************************************
// ViewResolver for the Thymeleaf
// ****************************************************************
@Bean
public ThymeleafViewResolver viewResolver(){
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(thymeleafEngine());
return viewResolver;
}
@Bean
public SpringTemplateEngine thymeleafEngine() {
SpringTemplateEngine thymeleafEngine = new SpringTemplateEngine();
thymeleafEngine.setTemplateResolver(templateResolver());
return thymeleafEngine;
}
@Bean
public ServletContextTemplateResolver templateResolver() {
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
templateResolver.setPrefix("/WEB-INF/views");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode("HTML5");
return templateResolver;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment