通过属性

时间:2018-04-25 14:29:26

标签: spring spring-mvc spring-boot

在Spring MVC控制器中,我想使用属性文件中的默认Pageable值。

@RequestMapping
public String list(Model model, @PageableDefault(size = 5, sort = "title") Pageable pageable) {
    // ...
}

我试图简单地写size = properties.getSize()但它需要一个常量。

如何通过属性文件配置sizesort参数?

  • 春季5
  • Spring Boot 2

1 个答案:

答案 0 :(得分:0)

 # 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.

或查找属性here