I want to use thymeleaf templates in my spring boot application. I've some html pages in the src/resources/public
directory and I want them to be served wihout writing a controller because I want to write a front end application. I can access the index.html
file at http://localhost:8080/index.html
but it's not using the thymeleaf syntax. How can I do it?
I've added the thymeleaf dependency, tried writing a SpringResourceTemplateResolver
bean but still no luck. Here is what I've done so far:
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
@Bean
public SpringResourceTemplateResolver templateResolver(){
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setPrefix("classpath:/public/");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode(TemplateMode.HTML);
templateResolver.setCacheable(true);
return templateResolver;
}
}