Description: Pageable can also be used to manipulate the paging of MongoDB.
An interface defined in the Pageablespring data library that is an abstraction of all paging-related information, through which we can get all the information related to paging (such as pagenumber, pagesize, etc.).
Pageable defines a number of methods, but its core information is only two: the first is the paging information (page, size), and the second is the sorted information.
In spring MVC's request, you simply define a pageable type parameter directly in the parameter of the method, and when spring finds this parameter, Spring automatically assembles the Pageable object according to the request's parameters. The request parameters supported by spring are as follows:
Page , page, starting from 0, default to page No. 0 size, size of each page, default to sort, sorting related information to Property,property (ASC| DESC) is organized in a way such as Sort=firstname&sort=lastname,desc, which is arranged in reverse order on the basis of the FirstName ordinal arrangement, according to LastName.
In this way, we can use the parameters of the URL for a variety of personalized query.
Spring data provides the default configuration for @pageabledefault to help us personalize the settings pageable. For example @PageableDefault (value = all, sort = {"id"}, Direction = Sort.Direction.DESC) means that by default we are listed in reverse order of ID, with a size of 15 per page.
@ResponseBody " List ", method=requestmethod.get) public"ID" }, Direction = Sort.Direction.DESC) pageable pageable) { return Blogrepository.findall (pageable); }
Reference:
http://blog.csdn.net/qq_30553235/article/details/76070541 (MongoDB)
http://blog.csdn.net/zsg88/article/details/66025560 (the above content is transferred from this article)
Spring MVC gets paging information through pageable objects and Pageabledefault annotations (MongoDB operates pagination via pageable)