If a struts 2 action class have a property of
List<User> userList.
And the user class has properties like
username, password, createdDate etc.
Is it possible to make struts populate the list by passing the appropriate JSON string, while submitting a jQuery ajax request pointed at that action.
If it is possible how? Specially how will the JSON string have to look like?
Please ask any clarifications.
EDIT : I’m sorry if I wasn’t clear enough. What I want to do is not get data from Action to a JSP, or submit a form to populate the data. I want to submit a AJAX request with JSON data which Struts 2 can use to automatically populate the List in the Action class.
Not submit the form with AJAX.
you should define your action result
type="json"and check you have json plugin on your classpath, make sure you haveedit your action class like this
then you can do some on your jsp page to show the result like:
I hope this can help you..
UPDATE
if you have already a json object:
this should be the format.
then you should get this object from your action class with
List<User> userListjust try it and feedback.
UPDATE 2
maybe you should get your json object using
String, then convert it to Java Object using:Please feedback again.