1
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..?

1
  • multiple object in the sence ? Commented Apr 23, 2015 at 10:52

1 Answer 1

1

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);
    }
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for reply. How we should call this in angularjs controller?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.