Question

i have a collection (an arraylist) in action class in which i m storing java mail api's Message class objects.

In jsp i want to access each message from this collection and wants to call msg.getFrom(),msg.getSubject() etc. to dipslay them in tabular form.

how to call methods on collection objects from jsp using struts2 tags or OGNL.

thanks...

Was it helpful?

Solution

Same way as in Java--just call the method. With getters, though, you access them as properties using normal JSP EL or OGNL.

<s:iterator value="msgs" var="msg">
    <!-- "#" may not be required depending on Struts 2 version. -->
    <s:property value="#msg.from"/> 
</s:iterator>

Or:

<c:forEach items="${msgs}" var="msg">
    ${msg.from}
</c:forEach>

(There are a few other variations as well.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top