Our REST APIs are returning results in Pages. Here is an example of one Controller
@RequestMapping(value = \"/search\", method = RequestMethod.GET, produces
Changed the code reading the Rest API response as;
ParameterizedTypeReference> responseType = new ParameterizedTypeReference>() { };
ResponseEntity> result = restTemplate.exchange(url, HttpMethod.GET, null/*httpEntity*/, responseType);
List searchResult = result.getBody().getContent();
And here is the class I created for RestResponsePage
package com.basf.gb.cube.seq.vaadinui.util;
import java.util.ArrayList;
import java.util.List;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
public class RestResponsePage extends PageImpl{
private static final long serialVersionUID = 3248189030448292002L;
public RestResponsePage(List content, Pageable pageable, long total) {
super(content, pageable, total);
// TODO Auto-generated constructor stub
}
public RestResponsePage(List content) {
super(content);
// TODO Auto-generated constructor stub
}
/* PageImpl does not have an empty constructor and this was causing an issue for RestTemplate to cast the Rest API response
* back to Page.
*/
public RestResponsePage() {
super(new ArrayList());
}
}