如何使用 jstl 将数据显示到 jsp 中的 table 的第二列?

How to display data into second column of a table in jsp by using jstl?

我想在 jsp 中显示一个 table,其中包含两列(日期、评级)。这是我的 jsp 代码:

<table id="results" ALIGN="center" BORDER="1" WIDTH="50%">
        <tr>
           <th>Date</th>
           <th>Rating</th>
        </tr>
          <c:forEach var="sDate" items="${currentSessionSelectDate}">
                <tr>
                   <td><center>${sDate}</center></td>
                </tr>
          </c:forEach>
          <c:forEach var="monthRating" items="${currentSessionMonthRating}">
                <tr>
                   <td><center>${monthRating}</center></td>
                </tr>
          </c:forEach>
</table>

"sDate" 是从数据库中检索到的数据集,将显示在 "Date" 列下,而 "monthRating" 是 "Rating" 列的数据集。

如何让 "monthRating" 显示在 "Rating" 列下?现在所有数据都显示在 "Date" 列下。 谢谢,如果你能帮忙。

如果您能够制作一个列表而不是两个列表,那么最好在 table 中迭代它。但是,如果你做不到,试试这个代码可能会有帮助:)

<table border="1">
        <tr>
            <td>Date</td>
            <td>Rating</td>
        </tr>
        <tr>
            <td>

                <table>
                    <c:forEach var="sDate" items="${currentSessionSelectDate}">
                        <tr>
                            <td>${sDate}</td>
                        </tr>
                    </c:forEach>
                </table>
            </td>

            <td>
                <table>
                    <c:forEach var="monthRating" items="${currentSessionMonthRating}">
                        <tr>
                            <td>${monthRating}</td>
                        </tr>
                    </c:forEach>
                </table>

            </td>
        </tr>
    </table>