On discussion with @Aleksandr I found the Answer. I am posting it here so that any one facing same problem can get a help form it.
To <s:iterator>
tag we can not pass JSON object & it's not at all needed. What I had to achieve is to make a ajax call & pass a result to the <s:iterator>
.
So no need to use a Struts2 json plugin. Simply use dispatcher
which is default result type of action in Struts2 which returns html. Simple steps are
Create separate JSP page say
List.jsp
which will contain<s:iterator>
tag to which we will pass the result(i.eList<myModel>
in my case).Give this
List.jsp
as a result page of our action as show below.<s:action name="myAction" class="package.MyClass"> <result name = "success">List.jsp</result> </s:action>
So on making ajax call we will get
List.jsp
(i.e html) as a response. Simply add this response data to the anydiv
you want.
That's it.