public class PageList<E> extends ArrayList<E> {
private static final long serialVersionUID = 1412759446332294208L;
private Paginator paginator;
public PageList() {}
public PageList(Collection<? extends E> c) {
super(c);
}
public PageList(Collection<? extends E> c,Paginator p) {
super(c);
this.paginator = p;
}
public PageList(Paginator p) {
this.paginator = p;
}
/**
* 得到分页器,通过Paginator可以得到总页数等值
* @return
*/
public Paginator getPaginator() {
return paginator;
}
}
如上面这个类,在toJSONString 我希望结果是
{
paginator:{
"slider": [1, 2, 3, 4, 5, 6, 7],
"hasPrePage":false,
"startRow": 1,
"offset": 0,
"lastPage":false,
"prePage": 1,
"hasNextPage":true,
"nextPage": 2,
"endRow": 30,
"totalCount": 40351,
"firstPage":true,
"totalPages": 1346,
"limit": 30,
"page": 1},
"items":[
{"NAME":"xiaoma","AGE":30,"GENDER":1,"ID":3,"CITY":"BeiJing"},
{"NAME":"xiaoli","AGE":30,"SCORE":85,"GENDER":1,"ID":1,"CITY":"BeiJing"},
{"NAME":"xiaowang","AGE":30,"SCORE":92,"GENDER":0,"ID":2,"CITY":"BeiJing"},
{"NAME":"xiaoshao","AGE":30,"SCORE":99,"GENDER":0,"ID":4,"CITY":"BeiJing"}
]}
而非
[
{"NAME":"xiaoma","AGE":30,"GENDER":1,"ID":3,"CITY":"BeiJing"},
{"NAME":"xiaoli","AGE":30,"SCORE":85,"GENDER":1,"ID":1,"CITY":"BeiJing"},
{"NAME":"xiaowang","AGE":30,"SCORE":92,"GENDER":0,"ID":2,"CITY":"BeiJing"},
{"NAME":"xiaoshao","AGE":30,"SCORE":99,"GENDER":0,"ID":4,"CITY":"BeiJing"}
]
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。