For example if you have a json object like:
{
"beans":[
{
"agreemendId":1,
"answerId":2
}
]
}
JQuery will map your parameters like
beans[0][agreementId]:1
beans[0][answerId]:2
The problem is that Spring MVC is expecting a parameter format like
beans[0].agreementId:1
beans[0].answerId:2
In order to get that you can do it in 1 of two ways. You can do the quick and dirty way, which changes the way you're building your json object. Or, the other way is to extend the jQuery plugin to build parameters differently.
To change the javascript code was pretty simple and looked something like this
var answers = {};
answers['beans[' + index +'].agreementId'] = agreementId;
answers['beans[' + index +'].answerId'] = value;
To modify the jquery plugin I would suggest taking a look here.
And for reference here are the pojos I was mapping to.
This comment has been removed by the author.
ReplyDelete