在 jsp 页面中垂直显示值列表

Show a List of value vertically in jsp page

<table class="table">
                <thead>
                    <tr>
                        <th scope="col">Book Id</th>
                        <th scope="col">Book Name</th>
                        <th scope="col">Book Author</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><c:forEach items="${searchedBook}" var="book">
                            ${book.book_id}
                        </c:forEach></td>
                    </tr>
                    <tr>
                        <td><c:forEach items="${searchedBook}" var="book">
                            ${book.book_name}
                        </c:forEach></td>
                    </tr>
                    <tr>
                        <td><c:forEach items="${searchedBook}" var="book">
                            ${book.book_author}
                        </c:forEach></td>
                    </tr>
                </tbody>
            </table>

how the table looks like now

但是我想要的是这样的, the way I want it to look like

有没有办法让它成为可能?

您在 <td> 标记内声明 forEach 循环,它在单个 <td>

中打印所有数据

这里修改代码:

<table class="table">
 <thead>
  <tr>
    <th scope="col">Book Id</th>
    <th scope="col">Book Name</th>
    <th scope="col">Book Author</th>
</tr>
</thead>
<tbody>
    <tr>
        <c:forEach items="${searchedBook}" var="book">
        <td>${book.book_id}</td>
        </c:forEach>
    </tr>
    <tr>
        <c:forEach items="${searchedBook}" var="book">
        <td>${book.book_name}</td>
        </c:forEach>
    </tr>
    <tr>
        <c:forEach items="${searchedBook}" var="book">
        <td>${book.book_author}</td>
        </c:forEach>
    </tr>
</tbody>
</table>