https://www.programmersought.com/article/1615785965/ : "Spring annotates paging by @PageableDefault of springframework.data" - can override https://www.javaer101.com/en/article/1361705.html
https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/web/PagedResourcesAssembler.html
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
few tweaks to make it work with the spring
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverers;
import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonLinkDiscoverer;
import org.springframework.plugin.core.SimplePluginRegistry;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
argumentResolvers.add(new PageableHandlerMethodArgumentResolver()); }
//https://stackoverflow.com/questions/58431876/why-hateoas-starts-creating-issue-for-spring-boot-version-2-2-x-during-startu
@Bean
public LinkDiscoverers discoverers() { List plugins = new ArrayList<>(); plugins.add(new CollectionJsonLinkDiscoverer()); return new LinkDiscoverers(SimplePluginRegistry.create(plugins)); }
@Configuration
@EnableSwagger2
MySwaggerConfig extends WebMvcConfigurationSupport {
@Override
public void addArgumentResolvers(List argumentResolvers) {
The pageable default page and size
The default-pagenumber the injected Pageable should get if no corresponding parameter defined in request (default is 0).
size -
The default-size the injected Pageable should get if no corresponding parameter defined in request (default is 10).
sort -
The properties to sort by by default.
value -
Alias for size()
adding pagination with mongo
pass in size,page,sort...
?sort=name&sort=email,asc