DATACMNS-692 - Fixed web parameter range handling for Pageables.
In case the PageableHandlerMethodArgumentResolver was configured to use one-indexed parameters, it wasn't defaulting the lower bounds for the page number. This caused indexes out of the allowed bound submitted causing an invalid index handed tor PageRequest. We now apply better range shifting before the bounds are applied.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -236,6 +236,23 @@ public class PageableHandlerMethodArgumentResolverUnitTests extends PageableDefa
|
||||
assertThat(result.getSort(), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-692
|
||||
*/
|
||||
@Test
|
||||
public void oneIndexedParametersDefaultsIndexOutOfRange() {
|
||||
|
||||
PageableHandlerMethodArgumentResolver resolver = getResolver();
|
||||
resolver.setOneIndexedParameters(true);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addParameter("page", "0");
|
||||
|
||||
Pageable result = resolver.resolveArgument(supportedMethodParameter, null, new ServletWebRequest(request), null);
|
||||
|
||||
assertThat(result.getPageNumber(), is(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PageableHandlerMethodArgumentResolver getResolver() {
|
||||
PageableHandlerMethodArgumentResolver resolver = new PageableHandlerMethodArgumentResolver();
|
||||
|
||||
Reference in New Issue
Block a user