Passing json as body and another object as parameter to spring controller

I’m passing back a list of objects as json to my spring controller, but I also need to pass it some customer details too such as firstname, lastname, address, payment type – so I thought I create a POJO for this and pass this as a request param but no luck.

Spring controller:

  @RequestMapping(value = "/addstock", method = RequestMethod.POST)
    public @ResponseBody
    String addPersons(@RequestBody StockList stock, @RequestParam(name="details") AddDetails details) throws ParseException, IOException

Pojo is AddDetails which has the getter/setter etc using lombok. I try to pass as follows in my javascript:

 function sendData() {
            var stocks = JSON.stringify({'stocks': model.stock()});
            var obj = { "firstname":"Steve", "lastname":"Green"};
            obj = JSON.stringify({'details':obj});
                type: 'POST',
                data:  stocks,
                dataType: "html",
                contentType: 'application/json',
                mimeType: 'application/json',
                success: function(data){
                    return false;

But obviously I cannot pass an object across to the details param. Is it possible another way?

Many thanks

64 thoughts on “Passing json as body and another object as parameter to spring controller”

  1. Hi there! I know this is kinda off topic but I was wondering which blog platform are you using
    for this website? I’m getting fed up of WordPress because I’ve had problems with hackers and I’m looking at options for another platform.
    I would be great if you could point me in the
    direction of a good platform.

  2. Woah! I’m really digging the template/theme of this blog.
    It’s simple, yet effective. A lot of times it’s tough to get that “perfect balance”
    between superb usability and visual appearance. I must say you have
    done a amazing job with this. Also, the blog
    loads extremely quick for me on Firefox. Superb Blog!

    Here is my web page: sky777 agent

  3. Saya telah menjelajah online lebih dari 2 jam hari ini, namun saya tidak pernah menemukan artikel menarik seperti milik Anda.

    It’s cukup berharga bagi saya. Menurut pendapat saya , jika semua pemilik web dan blogger membuat konten yang baik seperti yang Anda lakukan, net akan menjadi lebih berguna dari sebelumnya.

    Have a look at my web-site … Situs judi slotcom,,

  4. Hello! This is kind of off topic but I need
    some help from an established blog. Is it difficult to set up your own blog?
    I’m not very techincal but I can figure things out
    pretty fast. I’m thinking about creating my own but I’m not sure
    where to start. Do you have any points or suggestions?
    With thanks

    My blog ::

  5. I hardly comment, however i did a few searching and wound up here Passing json as body and another object
    as parameter to spring controller – JavaScript Help.

    And I actually do have 2 questions for you
    if it’s allright. Could it be just me or does it give the
    impression like some of the responses come across like coming from brain dead folks?
    😛 And, if you are posting on additional online social sites, I’d like
    to follow anything fresh you have to post. Would you
    list of every one of all your public pages like your twitter feed, Facebook
    page or linkedin profile?

    Look at my webpage … New Flow XL Pills

  6. I was wondering if you ever thought of changing the page
    layout of your website? Its very well written; I love what youve got to
    say. But maybe you could a little more in the way of content so people could
    connect with it better. Youve got an awful lot of text for only having 1 or two pictures.
    Maybe you could space it out better?

    Look at my web blog: id test wukong333

  7. Just desire to say your article is as amazing. The clearness for your
    submit is just spectacular and i could suppose you’re an expert in this subject.

    Well together with your permission allow me to seize your RSS
    feed to stay updated with impending post. Thank you a million and please keep
    up the enjoyable work.

    my site :: puccy888 (xe88sg.Com)

  8. hello there and thank you for your information – I’ve certainly picked
    up something new from right here. I did however expertise a few technical issues using this site, as I experienced to reload the
    site many times previous to I could get it to load correctly.
    I had been wondering if your hosting is OK? Not that I’m complaining, but slow loading instances times will sometimes affect
    your placement in google and could damage your high quality score if advertising and marketing with Adwords.
    Well I am adding this RSS to my e-mail and could look out for much more
    of your respective interesting content. Make sure you update this again soon.

    my blog: ntc33 download

  9. My spouse and i were very peaceful that Michael could finish up his investigations through your ideas he discovered through the site.
    It’s not at all simplistic to simply find yourself handing out ideas which people today might have been selling.

    And we also grasp we need the blog owner to appreciate because of that.
    The specific explanations you have made, the easy site menu, the relationships
    you assist to promote – it’s got all overwhelming,
    and it is leading our son and our family know that this subject is excellent, which is certainly pretty fundamental.
    Thank you for everything!

    my web site: Viag Rx

  10. whoah this weblog is magnificent i really like reading your posts.
    Stay up the good work! You realize, a lot of people are searching around for this info, you can aid
    them greatly.

    Also visit my homepage … ok388 trusted company (Raleigh)

  11. Basically to follow up on the up-date of this subject on your website and would
    like to let you know just how much I treasured the
    time you took to put together this valuable post. Within the post, you really spoke of how to actually handle
    this concern with all comfort. It would be my pleasure to gather some more strategies
    from your website and come as much as offer
    people what I learned from you. I appreciate your usual good effort.

    my homepage … Keto Boom BHB

  12. Hello there, just became alert to your blog through Google, and found that it is really
    informative. I?m gonna watch out for brussels. I?ll appreciate if you continue
    this in future. Lots of people will be benefited from your
    writing. Cheers!

    Feel free to visit my webpage; Keto Boom Reviews; Donte,

  13. Great goods from you, man. I have understand your stuff previous to and you’re just
    too great. I actually like what you’ve acquired here, certainly like what you’re stating and
    the way in which you say it. You make it enjoyable and you still care for to keep it sensible.

    I cant wait to read far more from you. This
    is really a terrific site.

    Here is my page Bodycor Keto Reviews

  14. After going over a few of the blog articles on your blog, I
    really appreciate your way of writing a blog. I bookmarked it to my bookmark site list and
    will be checking back soon. Please visit my website as well and let me know
    your opinion.

  15. Please let me қnow if you’ге looking
    for a artiсle author for youhr site. Yоu have some really gooⅾ articles and I feel I would be a good aѕset.
    If you ever wnt to take sоme of the ⅼoad ⲟff, I’d absolutelү
    love to write some material for your blog in exchange for
    a link back to mine. Please send me an e-mail if interested.
    Many thanks!

  16. Greetings from Florida! I’m bored to death at work so I decided to check
    out your site on my iphone during lunch break. I love the info you provide here and can’t wait to take a look when I get home.
    I’m amazed at how quick your blog loaded on my mobile ..

    I’m not even using WIFI, just 3G .. Anyhow, great blog!

    Here is my web-site: pussy88 slot

  17. Have you ever considered writing an ebook or guest authoring on other websites?
    I have a blog based upon on the same information you discuss and would love to
    have you share some stories/information. I
    know my visitors would value your work. If you are even remotely interested, feel
    free to send me an e mail.

    my site: Divine Dynamic Keto Pills (

  18. Hmm is anyone else encountering problems with the images on this
    blog loading? I’m trying to figure out if its a problem on my end or if it’s the blog.
    Any suggestions would be greatly appreciated.

  19. Hello there! This blog post couldn?t be written any better!
    Going through this post reminds me of my previous roommate!
    He continually kept talking about this. I will send this
    information to him. Pretty sure he’s going to have a
    great read. Thanks for sharing!

    My web-site; Phincat Weight Loss


Leave a Comment