Although I change @Controller to @RestContoller, it prints not index.html but "index"
It should bring html file in templates folder but it doesn't work
I also tried to add some properties
spring.thymeleaf.prefix=/templates
spring.thymeleaf.suffix=.html
in application.properties and its still not working
Thanks for help in advance
CodePudding user response:
Remove:
spring.thymeleaf.prefix=/templates
and just add this lines:
spring.thymeleaf.cache=false
spring.thymeleaf.mode=HTML
spring.thymeleaf.suffix=.html
CodePudding user response:
Make sure your pom contains thymeleaf dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Place the templates under src/main/resources/templates
folder. The default extension is .html
Make sure your controller has @RequestMapping
annotation
@Controller
@RequestMapping("/")
class MainController {
@GetMapping
public String viewHomePage() {
return "index";
}
}
Remove all configurations from application.properties