- 注册时间
- 2012-10-29
- 最后登录
- 2013-6-23
- 阅读权限
- 10
- 积分
- 135
- 精华
- 0
- 帖子
- 33
|
我想问一下我的json数据格式为:
[{"NUM":"10230","S_NUM":"10119","ZT":"D,人脑的芯片记忆移植尝试 ","TASJ":"2012-11-09 ","TARNAME":"韩冠兰","TAR":"glhan","LB":"新闻类","COUNT":0,"STATE":3}]
页面上就能够输出
如图所示:1
但如果采用分页的方式封装json时,格式如下:
[{"total":19,"data":[{"NUM":"10230","S_NUM":"10119","ZT":"D,人脑的芯片记忆移植尝试 ","TASJ":"2012-11-09 ","TARNAME":"韩冠兰","TAR":"glhan","LB":"新闻类","COUNT":0,"STATE":3}]}]
前台显示 :
2
这是怎么回事?
我操作数据库的代码是:
List dataAll = this.getJdbcTemplate().queryForList(sql); //操作数据库
List data = new ArrayList();
int start = pageIndex * pageSize;
int end = start + pageSize;
int i = 0;
for (int l = dataAll.size(); i < l; ++i) {
HashMap recode = (HashMap) dataAll.get(i);
if (recode == null)
continue;
if ((start <= i) && (i < end)) {
data.add(recode);
}
}
HashMap request = new HashMap();
request.put("data", data);
request.put("total", Integer.valueOf(dataAll.size()));
这种写法是根据你们后台操作数据库的方法一样。
|
|