使用了spring boot配合jpa,感觉是挺不错的。做一个简单的mysql数据库分页查询
很简单,直接上代码了。
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
//就不用写注释了吧。
Pageable pageable = PageRequest.of(Integer.parseInt(page), Integer.parseInt(limit));
Page<PicInfo> allPicturesPage = picDao.findAll(pageable);
List<PicInfo> allPictures = allPicturesPage.getContent();
之前用 Pageable pageable = new PageRequest(params) 的方法已经过时了,用 PageRequest.of 来代替了。