• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving List from DB and setting to JSP in struts 2

 
Mah Desh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In JSP when I use

<%@ taglib prefix="s" uri="/struts-tags" %>
<s:iterator value="list">
<s:property /><br>
</s:iterator>

It prints output as
com.PPP.ebusiness.vo.ReportVO@b2fb1e
com.PPP.ebusiness.vo.ReportVO@8497f6

Here list is a ArrayList containing value objects of type ReportVO.
I want to print properties of ReportVO, how can I do it using it using iterator tag?

I need to declare somewhere that list returns ReportVO type and then retrieve property of that.

Thank you in advance.
 
Mah Desh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its resolved. This worked

<s:iterator id="vo" value="list" status="com.ist.PPP.ebusiness.vo.ReportVO">
<s:property value="title"/><br>
..
..
</s:iterator>
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the status attribute is not necessary. Its used when you want to know the iteration status like iteration number, even/odd etc. The problem was you were using s:property without specifying any attribute so the toString method of ReportVO was called thus printing the weird output...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic