tags:

views:

794

answers:

1

Is it possible to get an Object's attribute through the property tag in struts?

For example, if I have a user object that consist of user name and email, is it possible to modify the code below to have it return the user name and email instead of the whole object?

print("<s:iterator value="UserObjects"><tr><td><s:property/></td> </tr></s:iterator>");

I don't know why it refuses to let me input struts tag into the question, sorry for the above

Currently the above returns everything in UserObjects.

Thanks!

+2  A: 

If you have a bean that has a method like this:

public String getMyProperty()
{
  return "Test";
}

you should be able to access it with the property tag like this:

<s:iterator value="myList">
  <s:property value="myProperty" />
</s:iterator>

Check out the 3rd example down on the struts iterator documentation.

carson
Thanks! that page helped me!
freshWoWer