如何在 thymeleaf 中动态添加变量到三元运算符

How to dynamically add a variable to ternary operator in thymeleaf

我正在尝试将一个变量从我的 spring 启动控制器传递到一个带有三元运算符的标题,但似乎没有任何效果。

<h1 th:text="${createEntry} ? 'Create a new Entry:' : 'Edit Entry no. ${id}'"/></h1>

returns

Edit Entry no. ${id}

正确的语法是什么?

<h1 th:text=${createEntry ? 'Create a new Entry:' : 'Edit Entry no. ' + id}" />

<h1 th:text="${createEntry} ? 'Create a new Entry:' : 'Edit Entry no. ' + ${id}"/>