1

Hi I am trying to override the default param name fo page size in Spring JPA to match that of the Kendo UI grid which needs to use

http://localhost:8080/retailers/all?page=1&pageSize=5

The JPA is producing

http://localhost:8080/retailers/all?page=1&size=5

I have tried adding

spring.data.rest.page-param-name=page spring.data.rest.limitParamName=pageSize 

to the application properties, but it doesn't seem to make any difference to the project.

My controller looks like this

@RequestMapping(method = RequestMethod.GET, value = "retailers/all") public ResponseEntity<Page<RetailerEntity>> retailers(Pageable pageable){ Page<RetailerEntity> retailers = retailerService.getAllRetailers(pageable); return new ResponseEntity<>(retailers, HttpStatus.OK); } 

and the repository is using the out of the box implementation

public interface RetailerRepository extends PagingAndSortingRepository<RetailerEntity, Integer> { } 

Any help is appreciated.

1
  • Hi, could you tell us which spring boot version are you using? Commented Jun 14, 2017 at 7:54

1 Answer 1

1

This problem could be related to the spring boot version. Changing application.properties works only for Spring Boot 1.2+. If you are using 1.1 or earlier version, you have two options:

1) Create a RepositoryRestConfigurer bean using a custom implementation of RepositoryRestConfigurerAdapter.

@Configuration class CustomRestMvcConfiguration { @Bean public RepositoryRestConfigurer repositoryRestConfigurer() { return new RepositoryRestConfigurerAdapter() { @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { config.setBasePath("/api"); } }; } } 

2) Create a component with a custom implementation of RepositoryRestConfigurer.

@Component public class CustomizedRestMvcConfiguration extends RepositoryRestConfigurerAdapter { @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { config.setBasePath("/api"); } } 

These examples are for the basePath property, you can change all the others in the same way. You can check for more details: the documentation

Sign up to request clarification or add additional context in comments.

1 Comment

I am using parent starter 1.5.4.RELEASE, It still doesn't update the entries in the properties file. I've been able to work around it by changing the client side parameters, but I thought this would be easier.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.