Thymelaf,嵌套th:文本不显示



带价格的嵌套span不显示,只显示带h4的span。如何解决这个问题?

<h4 th:text="${dish.name}">chicken fried salad <span th:text="${dish.getPrice()}">45</span></h4>

th:text覆盖其中所有内容

<h4>
<span th:text="${dish.name}">chicken fried salad</span>
<span th:text="${dish.price}">45</span>
</h4>

首先,正如前一位用户告诉您的那样,th:text=${dish.name}将覆盖您放入标记中的任何文本,并将放置dish.name的值。

第二,您只需要调用dish.price来查看.price属性的值,而不是dish.getPrice()

最新更新