freshWoWer
freshWoWer

Reputation: 64219

struts property tag to retrieve Object

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!

Upvotes: 2

Views: 2648

Answers (1)

carson
carson

Reputation: 5759

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.

Upvotes: 3

Related Questions