Nic*_*las 2 spring pagination spring-mvc spring-data-rest
@PageableDefault的文档说:
在将a
org.springframework.data.domain.Pageable注入控制器方法时,设置默认值的注释 。
当使用Spring Data REST时,有没有一种方法可以在不定义控制器的情况下设置默认值?
在如下所示的存储库中设置PageableDefault似乎不起作用。
Page<Player> findAll(@PageableDefault(size=5) Pageable pageable);
Run Code Online (Sandbox Code Playgroud)
您可以扩展RepositoryRestConfigurerAdapter配置以设置默认页面大小:
@Configuration
public class RepositoryRestConfig extends RepositoryRestConfigurerAdapter {
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration repositoryRestConfiguration) {
repositoryRestConfiguration.setDefaultPageSize(5);
}
}
Run Code Online (Sandbox Code Playgroud)
spring.data.rest.default-page-size=5
Run Code Online (Sandbox Code Playgroud)
# DATA REST (RepositoryRestProperties)
spring.data.rest.base-path= # Base path to be used by Spring Data REST to expose repository resources.
spring.data.rest.default-page-size= # Default size of pages.
spring.data.rest.detection-strategy=default # Strategy to use to determine which repositories get exposed.
spring.data.rest.enable-enum-translation= # Enable enum value translation via the Spring Data REST default resource bundle.
spring.data.rest.limit-param-name= # Name of the URL query string parameter that indicates how many results to return at once.
spring.data.rest.max-page-size= # Maximum size of pages.
spring.data.rest.page-param-name= # Name of the URL query string parameter that indicates what page to return.
spring.data.rest.return-body-on-create= # Return a response body after creating an entity.
spring.data.rest.return-body-on-update= # Return a response body after updating an entity.
spring.data.rest.sort-param-name= # Name of the URL query string parameter that indicates what direction to sort results.
Run Code Online (Sandbox Code Playgroud)
来源:https : //docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#appendix
| 归档时间: |
|
| 查看次数: |
4365 次 |
| 最近记录: |