2012-10-23 45 views
0

我試圖使用curl得到以下方法:問題與捲曲GET請求和Spring MVC請求映射

我使用捲曲如下:

curl -i -H Accept:application/json http://localhost:8080/kadjoukor/geolocations?findByPostcodeFirstChars%26postcodeFirstChars=7500 

然而,上述捲曲命令總是拿這個方法(從Roo的ITD),而不是上面的一個:

@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); 
    } 

我不知道我得到錯誤的。有人可以幫忙嗎?

回答

2

我得到的CURL語法錯誤。

我不應該試圖手動編碼&符號。這是問題的原因。

這裏是發送GET請求的適當方法:

curl -i -X GET -H Accept:application/json "http://localhost:8080/kadjoukor/geolocations?findByPostcodeFirstChars&postcodeFirstChars=7500" 

注意引號和&