Showing Arraylist values using Struts2 Json and JQuery

I am having comment class, I want to show its property values to jsp page using json

ListJson assigning values for Here we fetch value of commentList and totalcomments value in our jsp page.


In Jsp page

Struts2 Json and Jquery Example

Here we will fetch a action variable’s value in jsp page using JSON and jquery
Here I am using struts 2.3.4 for that we have to include struts-2-json-plugin-2.3.4.jar in class path or include it to your lib folder if you are using any IDE.

Action class

In struts.xml we have to extend json-default and result type shold be json. No need to specify path inside <result &rt;</result<


Jsp page

Here we are using $.getJSON(‘test’, { name: name1}, function(data) method to fetch json data.