【发布时间】:2022-01-25 23:32:18
【问题描述】:
不显示带有价格的嵌套跨度,仅显示带有 h4 的嵌套跨度。如何解决?
<h4 th:text="${dish.name}">chicken fried salad <span th:text="${dish.getPrice()}">45</span></h4>
【问题讨论】:
标签: java spring spring-boot thymeleaf
不显示带有价格的嵌套跨度,仅显示带有 h4 的嵌套跨度。如何解决?
<h4 th:text="${dish.name}">chicken fried salad <span th:text="${dish.getPrice()}">45</span></h4>
【问题讨论】:
标签: java spring spring-boot thymeleaf
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 而不是 dish.getPrice() 即可查看 .price 属性的值。
【讨论】: