2016-03-30 15 views
0

まあ、私は春のコントローラで、ネストされたJSONを取得しようとして取得していますバインディングジャクソンデータ使用してコントローラを春にJSONをネストされた「クライアントから送信されたリクエストが文法的に間違っていたの。」ポストは

私のコードが動作し、私は、ネストされたJSONフォーマットをしない場合は正しいデータ・バインディングを取得し、私はそれ多分何かが私のDTOには適切ではないと結論することができています。

curlコマンド:

CURL -i -H "Content-Type: application/json" -X POST http://localhost:8080/insertMapping -d '{"mapping": {"adobe_segment_id": "125", "dp_key_id": "1"}, "type": "adobe"}' 

JSON:

{"mapping": {"adobe_segment_id": "125", "dp_key_id": "1"}, "type": "adobe"} 

コントローラー:

@RequestMapping(value = "/insertMapping", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) 
public ResponseEntity<String> createUser(@RequestBody RequestBodyDTO mapping) { 
    LOG.info("/insertMapping" + " ,type:" + mapping.getType().getType()); 
    return null; 
} 

RequestBodyDTO:

public class RequestBodyDTO { 
private MappingDTO mapping; 
private TypeDTO type; 

public TypeDTO getType() { 
    return type; 
} 

public void setType(TypeDTO type) { 
    this.type = type; 
} 

public MappingDTO getMapping() { 
    return mapping; 
} 

public void setMapping(MappingDTO mapping) { 
    this.mapping = mapping; 
} 
} 

MappingDTO:

public class MappingDTO { 
// adobe 
private Integer adobe_segment_id; 
private Integer dp_key_id; 


public Integer getAdobe_segment_id() { 
    return adobe_segment_id; 
} 

public void setAdobe_segment_id(Integer adobe_segment_id) { 
    this.adobe_segment_id = adobe_segment_id; 
} 

public Integer getDp_key_id() { 
    return dp_key_id; 
} 

public void setDp_key_id(Integer dp_key_id) { 
    this.dp_key_id = dp_key_id; 
} 

} 

TypeDTO:私は "プライベートTypeDTOタイプ" を "プライベート文字列型" に変更した後に解決

public class TypeDTO { 
private String type; 

public String getType() { 
    return type; 
} 

public void setType(String type) { 
    this.type = type; 
} 

}

答えて

0

問題。