这里我声明了名为 someVariable 的变量并指定默认值 10:
<p th:with ="someVariable=10">
<p th:text ="someVariable=${someVariable}+${someVariable}"> </p>
<p th:text ="${someVariable}"> </p>
</p>
之后我更改了变量的值,但出现错误。
在 Thymeleaf 中声明变量后如何更改变量的值?
最佳答案
像这样:
<p th:with="someVariable=10">
<p th:with="someVariable=${someVariable + someVariable}">
<span th:text="${someVariable}"></span>
</p>
</p>
关于java - 使用默认值声明 Thymeleaf 变量后如何对其进行算术运算?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48534820/