关于使用thymeleaf接收参数及查询返回Map的回忆

关于查询结果返回为Map的记忆梳理

resultType设置为Map,那么返回的时候就是Map类型的数据
Map数据是KV结构,默认不起别名的情况下,Key是表的字段名.
起别名的情况下,Key是取的别名

关于Thymeleaf中获取Map数据的值的梳理

假设Thymeleaf接收的是一个List> incomeRecordList的List集合嵌套Map集合参数.此处的Map相当于一个实体类,只是实体类属性满足不了数据封装需求,因此使用Map进行封装.

获取示例:
<div th:each="incomeRecord:${incomeRecordList}">
                        <dd>
                            <span class="number" style="text-align:left;" th:text="${incomeRecordStat.count}">1</span>
                            <span class="number" th:text="${incomeRecord.get('productName')}">新手宝</span>
                            <span class="number name" style="text-align:center;" th:text="${#dates.format(incomeRecord.get('incomeDate'),'yyyy-MM-dd')}">2017-05-12</span>
                            <span class="profit" th:text="${incomeRecord.get('incomeMoney')}">12.6</span>
                        </dd>
                    </div>

每次遍历出来的都是一个Map对象,而这个Map对象的Value中封装了我需要的数据,需要通过Key来获取Value,比如:incomeRecord.get('incomeMoney')

你可能感兴趣的:(随笔,java,javascript)