Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Spring
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Paul Clapham
Sheriffs:
paul wheaton
Tim Cooke
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Piet Souris
Bartenders:
Mike London
Forum:
Spring
Spring controller not getting JSON POST data from JS file
Sujoy Choudhury
Ranch Hand
Posts: 136
I like...
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
From my JS file I am posting this JSON data.
myPayload[0].id=1&myPayload[0].name=Me&myPayload[0].pId=2&myPayload[0].pName=Dad
YUI Code:
var formElements = YAHOO.util.Connect.setForm("myFormId"); alert("New form elements:" + formElements); // Alerting POST data as shown above YAHOO.util.Connect.resetFormState(); YAHOO.util.Connect.asyncRequest("POST", "/mycontroller/save", { cache : false, success : function(res) { alert(res.responseText); }, failure : function(res) { alert(res.responseText); } }, formElements);
Controller Code:
@RequestMapping(value = "/save", method=RequestMethod.POST) @ResponseBody public String saveData(ModelMap mm, @ModelAttribute("myPayload") MyBean bean, BindingResult errors) { log.info("save:Called"); List<MyDTO> lst = bean.getList(); log.info("save:Number of records:" + lst.size()); return "Successfully Updated."; }
Bean Code:
public class MyBean { private List<MyDTO> myPayload = new AutoPopulatingList<MyDTO>(MyDTO.class); public List<MyDTO> getList() { return myPayload; } public void setList(List<MyDTO> mList) { this.myPayload = mList; } }
The list is still empty. The bean values are also empty. What is wrong here?
Thanks and Regards,
~Sujoy
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
How to read + operator using javascript
database best practice
using ajax and struts iterate tags
Urgent: How to use Indexed Properties
how do i make a radio button to be checked when a page loads up?
More...