0
春のブートサービスからデータにアクセスしたい。データの戻り値の型はList
ですが、アクセスするたびにリストは空です。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);
、response.getBody()
は空[]
です。
@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);
}
私はまたString
、およびPerson[]
てみましたが、何も働きました。
ありがとうございます!
消費しているREST APIで空の配列が返されていませんか? – g00glen00b
はい。そうです。問題はパラメータです。 – trap