Thymeleaf在替换中读取属性

时间:2017-05-05 17:45:29

标签: spring-boot thymeleaf

我有这段代码,其中tdk是我在SpringBoot文件中定义的公共变量application.properties,名为server.contextPath

我想知道是否有替换它的方法

<head th:replace="tdk/common/header :: common-header" />

类似

<head th:replace="@environment.get('server.contextPath')/common/header :: common-header" />

我正在使用

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
    <version>1.5.3.RELEASE</version>
</dependency>

我也试过了:

<head th:replace="~{${@environment.getProperty('serverContextPath') + '/common/header'} :: common-header}" />

有了这个结果:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "~{${@environment.getProperty('serverContextPath') + '/common/header'}", template might not exist or might not be accessible by any of the configured Template Resolvers (/tdk/registration/signup:6)

0 个答案:

没有答案