【问题标题】:Thymeleaf aggregation not workingThymeleaf 聚合不起作用
【发布时间】:2016-08-24 17:07:39
【问题描述】:

我们有以下代码:

<div th:each="client : ${clients}">
    <div th:each="purchase : ${client.purchases}">
        <div th:each="product : ${purchase.products}">
            <span th:text="${product.price}"></span>
            <!-- <span id="2" th:text="${#aggregates.sum(products.{price})}"> </span> -->
            <!-- <span id="2" th:text="${#aggregates.sum(products.![price])}"> </span>  -->
        </div>
    </div>
</div>

输出是:

5.25
4.20

如果我取消注释第一条评论,我会收到错误

Exception evaluating SpringEL expression: "#aggregates.sum(products.{price})" (clients/clients:84)

如果我只取消第二条评论,我会收到错误:

Exception evaluating SpringEL expression: "#aggregates.sum(products.![price])" (clients/clients:85)

我尝试使用http://demo-dspace-cris.cineca.it/bitstream/123456789/26/1/usingthymeleaf.pdf

我正在使用thymeleaf 2.1.4

它的工作原理!

我应该使用:

<span id="2" th:text="${#aggregates.sum(purchase.products.![price])}"> </span> 

【问题讨论】:

    标签: thymeleaf aggregation spring-el


    【解决方案1】:

    在这里发帖后我自己想通了!

    <div th:each="client : ${clients}">
    
                <div th:each="purchase : ${client.purchases}">
                    <span id="2"
                        th:text="${#aggregates.sum(purchase.products.![price])}"> </span>
                    <div th:each="product : ${purchase.products}">
                        <span th:text="${product.price}"></span>
    
                    </div>
                </div>
            </div>
    

    输出:

    9.45
    5.25
    4.20
    

    对我帮助很大的网站:http://forum.thymeleaf.org/aggregates-with-Spring-td3767446.html

    【讨论】:

      猜你喜欢
      • 2020-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多