BAEL-3010 (#7408)
* BAEL-3010 changing template dir * BAEL-3010 Add ThymeleafConfig
This commit is contained in:
parent
4062ad667d
commit
2c53cdd44e
|
@ -0,0 +1,23 @@
|
|||
package com.baeldung.thymeleaf;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.thymeleaf.templatemode.TemplateMode;
|
||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
|
||||
|
||||
@Configuration
|
||||
public class ThymeleafConfig {
|
||||
|
||||
@Bean
|
||||
public ClassLoaderTemplateResolver secondaryTemplateResolver() {
|
||||
ClassLoaderTemplateResolver secondaryTemplateResolver = new ClassLoaderTemplateResolver();
|
||||
secondaryTemplateResolver.setPrefix("templates-2/");
|
||||
secondaryTemplateResolver.setSuffix(".html");
|
||||
secondaryTemplateResolver.setTemplateMode(TemplateMode.HTML);
|
||||
secondaryTemplateResolver.setCharacterEncoding("UTF-8");
|
||||
secondaryTemplateResolver.setOrder(1);
|
||||
secondaryTemplateResolver.setCheckExistence(true);
|
||||
|
||||
return secondaryTemplateResolver;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.baeldung.thymeleaf.templatedir;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class HelloController {
|
||||
|
||||
@GetMapping("/hello")
|
||||
public String sayHello() {
|
||||
return "hello";
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
#spring.thymeleaf.prefix=classpath:/templates-2/
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Enums in Thymeleaf</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Hello from 'templates/templates-2'</h2>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue