开发者

JSTL forEach loop prints in unexpected order

I wish to print a screen and afterwards a bunch of seats:

mgi =img

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<HTML>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    </head>


<body dir="rtl">

    <%@  taglib        prefix="c"   uri="http://java.sun.com/jstl/core_rt" %>




 <table border="0" style="width: 100%" dir="rtl">
            <tr>
                <td colspan="3" >
                    <p align="center">
                        <mgi src="${initParam.seats开发者_Python百科Path}theater_screen.jpg" alt="Screen"/></a>

                    </p>
                </td>
            </tr>

                             <c:forEach var="seat" items="${seatsList}" varStatus="iter">

                             <c:if test="${seat.seatColumn == 1}"> <tr><td> ${seat.seatRow} </td>  </c:if>

                             <c:choose>
                                    <c:when test="${seat.status==3}"> <mgi src="${initParam.seatsPath}seat_taken.jpg" id="seat_${seat.seatRow}_${seat.seatColumn}" style=" padding-right: 2px; vertical-align: middle;" alt="מושב תפוס" /></a>  </c:when>
                                    <c:otherwise> <mgi src="${initParam.seatsPath}seat_clear.jpg" id="seat_${seat.seatRow}_${seat.seatColumn}" onclick="clickSeat(${seat.seatPK.id}, ${seat.seatRow}, ${seat.seatColumn})" style=" padding-right: 2px; vertical-align: middle;" alt="מושב פנוי" /></a>  </c:otherwise>
                             </c:choose>

                             <c:if test="${seat.seatColumn == seatsPerRow}"> </td><td> ${seat.seatRow} </td></tr>  </c:if>

                        </c:forEach>


</table>


</body>
</HTML>

but what i get is this:

seats

screen

seats rows (printed by the (c:if...) tag)

Sorry as my reputation is too low to upload a clarifying image


it turned out to be more of a html question as a <td align="center"> was missing at the first if inside the loop.

this is the full if:

 <c:if test="${seat.seatColumn == 1}"> <tr><td> ${seat.seatRow} </td><td align="center">  </c:if>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜