Spring -boot thymeleaf загружает HTML файл из пути к классам
У меня есть многомодульная структура проекта, как:
- application (parent module)
--- boot (web-app)
----- src/main/resources/templates/layout.html
---- todo (jar file)
----- src/main/resources/templates/home.html
и на моем контроллере:
@RequestMapping(value = "/home")
public String home() {
return "todo/home";
}
Я получаю сообщение об ошибке, как показано ниже:
Error resolving template "todo/home", template might not exist or
might not be accessible by any of the configured Template
Resolvers]
Нужна ли конфигурация, чтобы настроить что-то специально для весны для поиска шаблонов на пути к классам?
Ответы
Ответ 1
Добавление следующих свойств решает мою проблему:
spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false