0

Как дать доступ к папке с шаблонами?. Ведь очевидно, что шаблон существует.

Лог ошибки

2021-02-27 16:15:41.834 ERROR 100721 --- [nio-5000-exec-1] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-5000-exec-1] Exception processing template "index": Error resolving template [/parts/html/search], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "index" - line 4, col 14)

html

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'index')}">
    <body>
        <div th:replace="~{/parts/html/search}"></div>

Шаблон располагается по пути: /path/to/project/src/main/resources/templates/parts/html/search.html

1 ответ 1

0
@Bean
public TemplateResolver templateResolver() {
        TemplateResolver templateResolver = new ClassLoaderTemplateResolver();
        templateResolver.setPrefix("templates/");
        templateResolver.setCacheable(false);
        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode("HTML5");
        return templateResolver;
    }

https://stackoverflow.com/a/40167690

Это помогло. Если путь к ресурсам такой же как у меня.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.