【问题标题】:Thymeleaf, nested th:text does not showThymeleaf,嵌套 th:text 不显示
【发布时间】: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


    【解决方案1】:

    th:text 覆盖其中所有内容的内容。像这样的东西对你有用:

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

    【讨论】:

      【解决方案2】:

      首先,正如前一个用户告诉您的那样,th:text=${dish.name} 将覆盖您在标签内放置的任何文本,并将替换为 dish.name 的值。

      第二个 - 您只需调用 dish.price 而不是 dish.getPrice() 即可查看 .price 属性的值。

      【讨论】:

        猜你喜欢
        • 2021-01-19
        • 2021-12-09
        • 1970-01-01
        • 1970-01-01
        • 2017-10-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-01
        相关资源
        最近更新 更多