2

indexq.jspでを使用する<jsp:include file="include/data.jsp" />と、データが表示されませんでしたが、使用すると期待どおりに機能します。スコープまたは式言語の問題かどうかはわかりません。以下のコードも含めました。<%@ include file="include/data.jsp" %>

TaxiController.java

public class TaxiController extends HttpServlet {

    // codes...

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {

                // codes...
        req.setAttribute("taxi_list", taxiDao.getAll());
        req.getRequestDispatcher("/indexq.jsp").forward(req, resp);

    }
}

indexq.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!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=ISO-8859-1">
        <script src="js/jquery-1.10.1.min.js" ></script>
        <title>Taxi List</title>
    </head>
    <body>
        <%@ include file="include/form.jsp" %>
        <br />
        <jsp:include page="include/data.jsp"  />   
        <%-- <%@ include file="include/data.jsp" %> --%>  
    </body>
</html>

include/data.jsp

<table>
    <thead>
        <tr><th colspan="5">Data</th></tr>
        <tr>
            <th>Date</th>
            <th>Taxi Name</th>
            <th>Plate number</th>
            <th>Amount</th>
        </tr>
    </thead>
    <tbody>
        <c:forEach var="taxi" items="${taxi_list }" >
        <tr>
            <td>${taxi.date } </td>
            <td>${taxi.taxiName }</td>
            <td>${taxi.plateNum }</td>
            <td>${taxi.amount }</td>
        </tr>
        </c:forEach>
    </tbody>
</table>

ありがとう!

4

1 に答える 1