前台:
jsp页面上定义DataSet:
<model:dataset id="ds" cmd="XXX.XXX.XX.XXCommand" global="true" autoLoad="true" sortField="RECORD_DATE"
sortDirection="DESC">
<model:record>
<model:field name="deptName" type="string"></model:field>
<model:field name="organName" type="string"></model:field>
<model:field name="recordCount" type="string"></model:field>
<model:field name="recordDate" type="string"></model:field>
<model:field name="organId" type="string"></model:field>
</model:record>
</model:dataset>
record的field和下面的数组元素的key是对应的
ds.removeAll();//清空装数据的ds
//设置查询参数
command.setParameter("recordDate",strDate);
//通过dataset获取command查询的结果
command.execute("queryForMonthlyStatistics_window");
//获取command返回的结果对象,并找到rows里面的所有映射,封装类型为数据,数组的元素为 key:value
var dsetArr = command.returns.rows;
//遍历数组
for(var i=0;i< dsetArr.length-1;i++){
//dsetArr[i]["recordDate"] = strDate;
//把数组每个元素封装到ds的Record对象里面
ds.newRecord(dsetArr[i]);
}
后台: