Java 春天正在访问Thymeleaf中的配置变量。
我正在尝试将Spring中的配置变量传递给Thmyleaf模板。我已经成功地从配置文件中加载了带有注释值的变量,并可以通过System.out输出它。我只是无法在模板中呈现它 应用程序.yamlJava 春天正在访问Thymeleaf中的配置变量。,java,spring,thymeleaf,Java,Spring,Thymeleaf,我正在尝试将Spring中的配置变量传递给Thmyleaf模板。我已经成功地从配置文件中加载了带有注释值的变量,并可以通过System.out输出它。我只是无法在模板中呈现它 应用程序.yaml acmeUrl: url: https://www.acme.com 我的控制器 @Value("${acmeUrl.url}") private String acmeUrl; //grab from annotation and pass to the v
acmeUrl:
url: https://www.acme.com
我的控制器
@Value("${acmeUrl.url}")
private String acmeUrl;
//grab from annotation and pass to the view
modelView.addObject( "acmeUrl", this.acmeUrl );
我的Thmeleaf模板:
<span th:text="${acmeUrl}" />
以上工作。但是,当我尝试对返回querystring参数进行条件检查时,我什么也没有得到
<input type="hidden" name="return" th:value="${param.return != null ? param.return[0] : acmeUrl }" />
我的内联IF在这里看起来正确吗?很确定这是罪魁祸首,但不确定是否需要更改格式以使其正常工作?
根据这一点,正确的语法应该是:
th:value=“${param.return!=null}?{param.return[0]}:{acmeUrl}”
根据这一点,正确的语法应该是:
th:value=“${param.return!=null}?{param.return[0]}:{acmeUrl}”