2016-07-04 2 views
0

스프링 부트 서비스에서 데이터에 액세스하려고합니다. 데이터의 반환 형식은 List이지만 액세스 할 때마다 목록은 비어 있습니다. response.getBody()[]이며,이 경우목록으로 RestTemplate에서 데이터에 액세스하는 방법

Map<String, String> params = new HashMap<String, String>(); 
params.put("firstName", "test"); 
params.put("lastName", "test1"); 
ResponseEntity<Person[]> response = restTemplate.getForEntity(url, Person[].class, params); 

:

내 코드입니다.

@RequestMapping(value = "/search", method = RequestMethod.GET) 
public List<Person> searchUsers(
     @RequestParam(value = "firstName", required = false) String firstName, 
     @RequestParam(value = "lastName", required = false) String lastName, 
     @RequestParam(value = "email", required = false) String email { 

    return personService.search(firstName, lastName, email, company); 
} 

나는 또한 StringPerson[]으로 시도했지만 아무것도 작동하지 않습니다.

미리 감사드립니다.

+0

소비하는 REST API가 빈 배열을 반환하지 않습니까? – g00glen00b

+0

예. 그것은. 문제는 매개 변수입니다. – trap

답변

1
@GET 
@Path("statement") 
@Produces({MediaType.APPLICATION_XML}) 
public Response statement(@QueryParam("from") String from, @QueryParam("to") String to) { 
    DB idb = new DB(); 
    List<Transaction> transactions = idb.getTransactionsByDate(from, to); 
    final GenericEntity<List<Transaction>> entity = new GenericEntity<List<Transaction>>(transactions) { 
    }; 
    return Response.status(Response.Status.OK).entity(entity).build(); 
} 
관련 문제