springboot-Thymeleaf语法取值

jyzhsk 2020-07-22 11:31:24
报错:2020-07-22 23:24:19.447 ERROR 7296 --- [nio-8080-exec-8] org.thymeleaf.TemplateEngine : THYMELEAF Exception processing template "front/cart": Exception evaluating SpringEL expression: "item.num" (template: "front/cart" - line 101, col 44)

org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "item.num" (template: "front/cart" - line 101, col 44)

<table class="table table-hover table-striped table-bordered">
<tr>
<th>
<input type="checkbox" id="all">全选</th>
<th>序号</th>
<th>商品名称</th>
<th>商品图片</th>
<th>商品数量</th>
<th>商品总价</th>
<th>操作</th>
</tr>
<tr th:each="item,i:${session.cart}">
<td>
<input type="checkbox">
</td>
<td>[[${i.index+1}]]</td>
<td></td>
<td> <img th:src="${item.value.product.image}" alt="" width="60" height="60"></td>
<td>
<input type="text" th:value="${item.num}" size="5">
</td>
<td>[[${item.value.price}]]</td>
<td>
<button class="btn btn-success" type="button"> <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>修改</button>
<button class="btn btn-danger" type="button" onclick="javaScript:return confirm('是否确认删除');">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
</button>
</td>
</tr>

<tr>
<td colspan="7" align="right">
<button class="btn btn-warning margin-right-15" type="button" > 删除选中项</button>
<button class="btn btn-warning margin-right-15" type="button" > 清空购物车</button>
<button class="btn btn-warning margin-right-15" type="button" > 继续购物</button>
<a href="order.html"><button class="btn btn-warning " type="button" > 结算</button></a>

</td>

</tr>
<tr>
<td colspan="7" align="right" class="foot-msg">
总计: <b><span>1000</span> </b>元
</td>

</tr>
</table>
cart是放在session作用域的Map集合,在Thymeleaf取值时应该时item.value.num

...全文
74 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,504

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧