Reputation: 33
var Buyers = [ { "first_name" : "Raj", "last_name" : "Pilla"
}, { "first_name" : "Ajit", "last_name" : "Bambaras"
} ]; var Seller = { "first_name" : "Simon", "last_name" : "Mathew" };
How we can post this data to controller using angular js post method also what we need to write in java controller..?
Upvotes: 1
Views: 155
Reputation: 4477
Yes, if you are trying to post multiple objects of the same type. You just need to use a list.
For e.g., in your case it will be :
public @ResponseBody String PostService(@RequestBody List<Seller> seller) {
}
However, if you're trying to send multiple objects of different types, you should instead use List to capture all the objects and then cast them as required.
For e.g.
public @ResponseBody String PostService(@RequestBody List<Object> requestObjects) {
Seller seller = (Seller) requestObjects.get(0);
Buyer buyer = (Buyer) requestObjects.get(1);
}
Upvotes: 1