yam*_*ami 5 aggregation spring-el thymeleaf
我们有以下代码:
<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>
Run Code Online (Sandbox Code Playgroud)
输出是:
5.25
4.20
Run Code Online (Sandbox Code Playgroud)
如果我取消注释第一条评论,则会收到错误
Exception evaluating SpringEL expression: "#aggregates.sum(products.{price})" (clients/clients:84)
Run Code Online (Sandbox Code Playgroud)
如果我仅取消第二条评论的注释,则会收到错误:
Exception evaluating SpringEL expression: "#aggregates.sum(products.![price])" (clients/clients:85)
Run Code Online (Sandbox Code Playgroud)
我尝试使用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>
Run Code Online (Sandbox Code Playgroud)
我在这里发帖后自己想通了!
<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>
Run Code Online (Sandbox Code Playgroud)
输出:
9.45
5.25
4.20
Run Code Online (Sandbox Code Playgroud)
网站对我帮助很大:http://forum.thymeleaf.org/aggregates-with-Spring-td3767446.html
| 归档时间: |
|
| 查看次数: |
4338 次 |
| 最近记录: |