Created
April 27, 2012 11:13
-
-
Save keesun/2508457 to your computer and use it in GitHub Desktop.
adding thymeleaf to spring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Cantabille</title> | |
</head> | |
<body> | |
Init Cantabille | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.thymeleaf</groupId> | |
<artifactId>thymeleaf-spring3</artifactId> | |
<version>2.0.5</version> | |
<scope>compile</scope> | |
</dependency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// **************************************************************** | |
// 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