문제

I'm quite certain I'm missing something utterly insignificant, but I've not been able to figure it out.

I'm using struts 2 tags in my jsp to iterate over an object and display the results. This is conditional, there's a check to see if the object is not null before it can iterate. The if part works perfectly, it prints out the list of movies. But the else does not seem to work.

    <s:if test="%{listmovies != null}">
        <s:iterator value="listmovies">
            <s:property value="title" />
            <br>
        </s:iterator>
    </s:if>
    <s:else>No movies!</s:else>
도움이 되었습니까?

해결책

Recheck that your listmovies is not an empty collection and invert your condition to simplify it:

<s:if test="%{listmovies.isEmpty()}">No movies!</s:if>
<s:else>
    <s:iterator value="listmovies">
        <s:property value="title" />
        <br>
    </s:iterator>
</s:else>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top