我的html其他页面位于编辑文件夹中。
我目前正在使用此脚本
<!--/*/ <th:block th:include="fragments/header :: header"></th:block> /*/-->
如果html文档位于同一目录中,则上述脚本有效。 (例如; index.html能够读取片段)。但我创建了一个新目录(名为:edit)来存储我的html页面。我需要退出当前文件夹,以便能够使用../
找到片段文件夹<!--/*/ <th:block th:include="../fragments/header :: header"></th:block> /*/-->
但这种方法不起作用。我怎样才能使用这种语法退出文件夹?
答案 0 :(得分:6)
看起来你正在使用Spring Boot。 Spring Boot自动配置Thymeleaf以查找/templates
中的所有HTML文件。
在default application.properties中,您可以看到它:
spring.thymeleaf.prefix=classpath:/templates/
所以(因为Thymeleaf使用/templates
作为root)应该有效:
<th:block th:include="fragments/header :: header"></th:block>
和/或:
<th:block th:include="/fragments/header :: header"></th:block>
你不需要退出当前文件夹&#34;。
答案 1 :(得分:-3)
我以前没有使用过Thymeleaf,但这forum post可能对你有用。
似乎表明有一种方法可以设置使用前缀和后缀机制的路径,以避免在此阶段提供路径本身