CURLを使用して次のメソッドを取得しようとしています。
@RooWebJson(jsonObject = Geolocation.class)
@Controller
@RequestMapping("/geolocations")
public class GeolocationController {
@Autowired
private GeolocationRepository geolocationRepository;
@RequestMapping(params = "findByPostcodeFirstChars", method = RequestMethod.GET, headers = "Accept=application/json")
@ResponseBody
public ResponseEntity<String> jsonFindGeolocationsByPostcodeFirstChars(@RequestParam("postcodeFirstChars") String postcodeFirstChars) {
System.out.println("jsonFindGeolocationsByPostcodeFirstChars");
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
List<Geolocation> geolocations = geolocationRepository.findByPostcodeStartingWith(postcodeFirstChars);
return new ResponseEntity<String>(Geolocation.toJsonArray(geolocations), headers, HttpStatus.OK);
}
}
私は次のようにCURLを使用します。
curl -i -H Accept:application/json http://localhost:8080/kadjoukor/geolocations?findByPostcodeFirstChars%26postcodeFirstChars=7500
ただし、上記のCURLコマンドは、上記のメソッドではなく、常にこのメソッド(Roo ITDから)をGETします。
@RequestMapping(headers = "Accept=application/json")
@ResponseBody
public ResponseEntity<String> GeolocationController.listJson() {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
List<Geolocation> result = geolocationRepository.findAll();
return new ResponseEntity<String>(Geolocation.toJsonArray(result), headers, HttpStatus.OK);
}
何が間違っているのかわかりません。誰か助けてもらえますか?