How To Send JSON Data From Ajax To Action Class | Struts2

08:26

Most of us want to send JSON formatted data from jquery ajax call to action class in struts2 framework of java, and there are so many examples and codes on the internet shows how to send this JSON format data from an ajax to action class in struts2. But, this code is tested and working well.


Most of the things i have done in this work such as: 

  • Some properties of jquery ajax method while sending request to action class. (contentType, dataType)
  • Which format of JSON we have to send in ajax call.
  • What are the interceptors i have used in struts.xml file for collection JSON data from ajax call.
  • Return type of action is json type used in struts.xml file.
  • Bean class having fields of our keys used in JSON object sent from jquery. (NAME OF FIELDS SHOULD BE SAME AS KEYS USED IN JSON OBJECT AND STARTED FROM SMALL LETTER)
  • Create LIST (of type Bean class) named same as key used for array in JSON object sent from jquery ajax. 


After reading these points if you watch my video you will definitely understand how to send json format data from jquery ajax call to action class in struts2 framework of java.



You Might Also Like

0 comments

If you have any questions or suggestions, you are free to ask, i will appreciate that and, i will try my best...

Google Ads