Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i get json in struts 2 action class through ajax call?
    primarykey
    data
    text
    <p>I have an application with struts 2 and i want to sensd a json using ajax call to action class. My ajax looks like this:</p> <pre><code>var data = {{userName:"userName",password:"password",userId:"userId"}, {userName:"userName",password:"password",userId:"userId"}, {userName:"userName",password:"password",userId:"userId"} } var users= JSON.stringify(data); $.ajax({ data: users, type: "POST", url: "http://localhost:8080/Example_Project/Example.action", contentType: "application/json", dataType: "json" }) Action.class public class ExampleAction extends ActionSupport { private List&lt;User&gt; users; public List&lt;User&gt; getUsers() { return users; } public void setUsers(List&lt;User&gt; users) { this.users = users; } public String addUsers(){ //code to inser user list return "success"; } } User.java public class User{ private String ;//getters and setters for it private String password;//getters and setters for it private Integer userId;//getters and setters for it } struts.xml &lt;struts&gt; &lt;package name="default" extends="struts-default,json-default" &gt; &lt;action name="Example" class="com.json.action.ExampleAction" method="addUsers"&gt; &lt;result name="success"&gt;/success.jsp&lt;/result&gt; &lt;/action&gt; &lt;/package&gt; &lt;/struts&gt; </code></pre> <p>I am using struts2-core 2.3.1.2 ,struts2-json-plugin 2.3.1.2 and json-rpc 1.0.How can i get the users data in action class.With the above code i am getting null in users variable in the action class.Please help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload