简体   繁体   中英

How can I print List<Object[]> with Struts 2?

In my java action class I have:

List<Object[]> objlistwitharry;

How can I display this in JSP with Struts2 ? I've tried :

<s:iterator value="objlistwitharry" var="emp">
    <s:property value="id" /><br/>
    <s:property value="name" /><br/>
    <s:property value="role" />
</s:iterator>

and

<s:iterator value="objlistwitharry" >
    <s:property value="id" /><br/>
    <s:property value="name" /><br/>
    <s:property value="role" />
</s:iterator>

but none of the above solution is working.

With var :

<s:iterator value="objlistwitharry" var="currentListElementThatIsAnArray">
    <s:iterator value="currentListElementThatIsAnArray" var="currentArrayElement">
        <s:property value="id" /><br/>
        <s:property value="name" /><br/>
        <s:property value="role" />
    </s:iterator>
</s:iterator>

or with top :

<s:iterator value="objlistwitharry">
    <s:iterator value="top">
        <s:property value="id" /><br/>
        <s:property value="name" /><br/>
        <s:property value="role" />
    </s:iterator>
</s:iterator>

and IIRC even this works:

<s:iterator value="objlistwitharry">
    <s:iterator>
        <s:property value="id" /><br/>
        <s:property value="name" /><br/>
        <s:property value="role" />
    </s:iterator>
</s:iterator>

Read more on the topic.

PS: even if it's possible to iterate it, consider the usage of better shaped structures for the future...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM