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});
            $.ajax({
                url:"/addstock?details="+obj,
                type: 'POST',
                data:  stocks,
                dataType: "html",
                contentType: 'application/json',
                mimeType: 'application/json',
                success: function(data){
                    console.log(data);
                    return false;
                }
            });
        }

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

Many thanks

339 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.

    Reply
  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

    Reply
  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, gameaco.com,

    Reply
  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 :: bbs.yunweishidai.com

    Reply
  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

    Reply
  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

    Reply
  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)

    Reply
  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

    Reply
  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

    Reply
  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)

    Reply
  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

    Reply
  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,

    Reply
  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

    Reply
  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.

    Reply
  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!

    Reply
  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

    Reply
  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 (marchegabonais.com)

    Reply
  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.

    Reply
  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

    Reply
  20. Pingback: keto protein
  21. I absolutely love your blog.. Great colors & theme.
    Did you create this amazing site yourself? Please reply back as I’m
    planning to create my own site and would like to know where
    you got this from or exactly what the theme is named.
    Thank you!

    Also visit my web site – Total Pure CBD Oil

    Reply
  22. Heya i am for the first time here. I came across this
    board and I find It really useful & it helped me out much.
    I hope to give something back and help others like you aided me.

    Reply
  23. Hi, Neat post. There is a problem with your site in web explorer, might test this?

    IE nonetheless is the market chief and a huge component to folks will leave out your magnificent writing due to this problem.

    Reply
  24. Hello terrific website! Does running a blog such as this require a large amount of work?
    I’ve no understanding of computer programming however I was
    hoping to start my own blog in the near future. Anyhow, should you have any recommendations or techniques for new blog owners
    please share. I know this is off subject but I just had to ask.
    Appreciate it!

    Also visit my site … Blitz Eagle CBD

    Reply
  25. Excellent post. Keep writing such kind of information on your site.
    Im really impressed by your blog.
    Hello there, You’ve done an incredible job. I will definitely digg it and personally recommend to my
    friends. I am confident they will be benefited from
    this website.

    Reply
  26. I would like to consider the ability of thanking you for that professional instruction I have usually enjoyed visiting your site.
    I will be looking forward to the particular commencement of my university research and the overall preparation would never have been complete without coming over to your blog.
    If I can be of any assistance to others, I might
    be happy to help by way of what I have learned from here.

    my web page GrownMD

    Reply
  27. Greetings from Carolina! I’m bored at work so I decided to check out your blog on my iphone during lunch break.
    I love the information you present here and can’t wait to take a look when I get
    home. I’m shocked at how quick your blog loaded on my cell phone ..
    I’m not even using WIFI, just 3G .. Anyhow, good blog!

    Feel free to surf to my page :: Keto Incinerate

    Reply
  28. Hello There. I found your blog using msn. This is an extremely well written article.

    I’ll be sure to bookmark it and come back to read more of your
    useful info. Thanks for the post. I will definitely return.

    Also visit my blog – MaxBHB

    Reply
  29. You really make it seem so easy with your presentation but I find this matter to be really something that I think I would never understand.
    It seems too complex and extremely broad for me. I’m looking forward for your
    next post, I’ll try to get the hang of it!

    my homepage … Yec Keto Reviews

    Reply
  30. excellent issues altogether, you just received a logo new reader.
    What would you suggest in regards to your post that you just made
    a few days in the past? Any positive?

    My web site :: Bill

    Reply
  31. Great post. I was checking constantly this blog and I’m impressed!
    Extremely useful information specially the
    last part 🙂 I care for such info much. I was seeking this particular information for
    a long time. Thank you and best of luck.

    My web site :: Pilar

    Reply
  32. I am extremely impressed with your writing skills
    as well as with the layout on your blog. Is this a paid theme
    or did you customize it yourself? Anyway keep up the excellent quality writing,
    it is rare to see a great blog like this one these days.

    My web page; 98e.fun

    Reply
  33. Howdy! I could have sworn I’ve been to this blog before but after looking at many of
    the posts I realized it’s new to me. Anyhow, I’m certainly delighted
    I came across it and I’ll be book-marking it
    and checking back frequently!

    Take a look at my web-site: adult acne

    Reply
  34. I do not even understand how I finished up right here, however
    I believed this put up used to be good. I don’t recognise who
    you’re however certainly you are going to a well-known blogger should you
    are not already. Cheers!

    Visit my web blog bad skin

    Reply
  35. Pingback: gay seniors dating
  36. Great ? I should certainly pronounce, impressed with your web site.
    I had no trouble navigating through all tabs as well as related info ended
    up being truly easy to do to access. I recently found what I hoped for before you know it at all.
    Quite unusual. Is likely to appreciate it for those who add forums or anything,
    website theme . a tones way for your client to communicate.
    Excellent task.

    Also visit my website – sexual intercourse

    Reply
  37. Excellent beat ! I would like to apprentice while you amend your site, how could i subscribe
    for a blog web site? The account helped me a appropriate deal.

    I have been tiny bit familiar of this your broadcast provided bright transparent idea.

    Here is my homepage … weed seeds

    Reply
  38. Hey this is kinda of off topic but I was wondering if blogs use
    WYSIWYG editors or if you have to manually
    code with HTML. I’m starting a blog soon but have no coding skills
    so I wanted to get guidance from someone with experience.
    Any help would be enormously appreciated!

    Reply
  39. Pingback: extra super viagra
  40. Pingback: canadianmed cialis
  41. Pingback: buy generic cialis
  42. Pingback: viagra price