我有一个如下实现的REST API:
@RequestMapping(value = "url/url", method = RequestMethod.POST)
MessageQueueResponse getOutboundQueueMessages (@RequestBody(required=true)Myclass myclass, @RequestParam(value = "value", required = true) String value)
{
//something
}
class Myclass {
Pair<Date,Date> range;
//getter, setters etc
}
从客户端我试图将其作为JSON发送:
var d = new Date();
var n = d.toJSON();
$http({
method: 'POST',
url: 'url/url',
params: {value:"myvalue"},
data: {range:{n:n}}
}).success(function(response){
//after success
}).error(function(){
//after failure
});
我收到400 Bad请求。如何在客户端以json格式表示Pair对象?