I am working on Spring Boot Spring Data Mongo Pageable example. I want to set pagination value default page=1
and size=5
, if no one provided any values.
Now when user provided any values, I want Pageable object to use those values and not default one.
Crated Bug: https://jira.spring.io/browse/DATAMONGO-2313
Its not working in my case. I'm not using Spring HATEOAS
in my application.
@GetMapping()
public ResponseEntity<Page<Student>> getAllstudents(Pageable pageable){
return studentService.findAllstudents(pageable);
}
in application.yml
file
# Mongo DB details
data:
mongodb:
database: TEST
host: localhost
port: 27017
web:
pageable:
default-page-size: 2
size-parameter: 0
one-indexed-parameters: true
page-parameter: page
Or I want exactly like below using Spring boot
<mvc:argument-resolvers>
<bean class="org.springframework.data.web.PageableHandlerMethodArgumentResolver" >
<property name="oneIndexedParameters" value="true"></property>
<property name="pageParameterName" value="page"></property>
<property name="sizeParameterName" value="size"></property>
<property name="fallbackPageable">
<bean class="org.springframework.data.domain.PageRequest">
<constructor-arg name="page" value="1" />
<constructor-arg name="size" value="${paging.default.pageSize}" />
</bean>
</property>
</bean>
</mvc:argument-resolvers>
Swagger UI: