Dear all,

I have got a performance issue on a nested iterator, running Struts
2.3.1.1.

Consider the code below, (the example is a Book with chapters and
subchapters and we're displaying the book index -  bookIndex is a
Map<Chapter,List<Subchapter>>.

This takes several seconds to load (map has size 10, each list is no
more than 15 items). I tried a lot of different approaches (mainly
regarding the database). However, what really surprised me was the
contents of the innermost <td> (6th row from the end): if I replace the
<s:a> with anything else (a xx, or just an <a>xx</a>) the page will load
much faster (ie, page load drops from 8 to 2 seconds).

Looking at http://struts.apache.org/2.x/docs/performance-tuning.html, I
double checked the OGNL version loaded in maven and indeed I have 3.0.3.

Is there any obvious reason why I'm getting such a slow performance?

Thanks for the input!

Miguel Almeida


Example code:

<s:iterator value="%{#bookIndex}" status="row" var="chapterIndex">
        <s:set var="chapter" value="%{#bookIndex.key}"/>
        <s:set var="subchapters" value="%{#chapterIndex.value}"/>
        <br>
        <s:url id="url" action="chapterloadPage">
                <s:param name="page">${chapter.firstPage}</s:param>
        </s:url>
        <s:a href="%{url}">${chapter.name}</s:a>        
                <table>
                        <s:iterator value="%{#subchapters}" status="ind" 
var="subchapter">              
                                        <s:url id="url" 
action="chapterloadPage">
                                                <s:param name="page"><s:property
value="%{#subchapter.page}"/></s:param>
                                        </s:url>
                                        <tr>
                                                <td> 
                                                        <s:a 
href="%{url}"><s:property
value="%{#subchapter.title}"/></s:a>
                                                </td>
                                        </tr>
                        </s:iterator>
                </table>
</s:iterator>

Reply via email to