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

Comments.java

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

Struts.xml

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<

struts.xml

Jsp page

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