需传参数:pageSize (required = false,defaultValue=10)     bookId (required = false,defaultValue = " ")

假设已经获得集合   list<Book> 对象,对其进行分页显示:

boolean flag = false;

int sum = 0;

List<Book> bookList = new ArrayList<Book>();

for(int i=0;i<list.size;i++){

Book book = list.get(i);

if(flag){

if(sum<pageSize){

bookList.add(good);

sum+=1;

}else{

break;

}

}else{

if(goodsId.equals(" "){

bookList.add(book);

flag = true;

sum +=1;

}else if(bookId.equals(book.getId()){

flag = true;

}

}

}

Map<String,Object> map = new HashMap<String,Object>();

map.put("bookList",bookList);

返回map对象即为需查找的分页内容!

 

} else {break;}} else {

posted on 2019-02-23 21:58  qqzhulu  阅读(368)  评论(0编辑  收藏  举报