前提・実現したいこと
現在tableタグを使って
formからDBに入力した情報をサーブレットを通してtable内に表示したいのですが、
ヘッダーを固定してbodyの部分を<forEachで繰り返し処理したいのですが、
ヘッダー部分でエラーが発生してしまい、原因がわかりません。
どうか知恵をお貸し頂きたいです。
JSP
1 <table class="Truck_table"> 2 <thead> 3 <tr> 4 <th class="space1" rowspan="2" colspan="3"></th> 5 <th class="Day1" colspan="4"><fmt:formatDate value='${trucks.task_date}' pattern='yyyy年MM月dd日(E)' /></th> 6 <th class="Day2" colspan="4"></th> 7 <th class="Day3" colspan="4"></th> 8 </tr> 9 <tr> 10 <th></th> 11 <th></th> 12 <th></th> 13 <th></th> 14 <th></th> 15 <th></th> 16 <th></th> 17 <th></th> 18 <th></th> 19 <th></th> 20 <th></th> 21 <th></th> 22 </tr> 23 </thead><%-- ここまでは繰り返さない --%> 24 <c:forEach var="trucks" items="${trucks}" varStatus="status"><%-- ここから繰り返し処理 --%> 25 <tbody> 26 <tr> 27 <td class="mw_time"></td> 28 <td class="sa_time"></td> 29 <td class="wa_time"></td> 30 <td class="es_time"></td> 31 <td class=""></td> 32 <td class=""></td> 33 <td class=""></td> 34 <td class=""></td> 35 <td class=""></td> 36 <td class=""></td> 37 <td class=""></td> 38 <td class=""></td> 39 </tr> 40 <tr> 41 <td class="拠点名"><c:out value="${trucks.office_name}"></c:out></td> 42 <td class="車番"><c:out value="${trucks.truck_code}"></c:out></td> 43 <td class="車種"><c:out value="${trucks.truck_type}"></c:out></td> 44 <td class ="宵積卸地"></td> 45 <td class ="積地"><c:out value="${trucks.stack_area}"></c:out></td> 46 <td class ="卸地"><c:out value="${trucks.wholesale_area}"></c:out></td> 47 <td class ="宵積"></td> 48 <td class ="宵積卸地2"></td> 49 <td class ="積地2"></td> 50 <td class ="卸地2"></td> 51 <td class ="宵積2"></td> 52 <td class ="宵積卸地3"></td> 53 <td class ="積地3"></td> 54 <td class ="卸地3"></td> 55 <td class ="宵積3"></td> 56 <tr> 57 <td class="mw_time"></td> 58 <td class="sa_time"></td> 59 <td class="wa_time"></td> 60 <td class="es_time"></td> 61 <td class=""></td> 62 <td class=""></td> 63 <td class=""></td> 64 <td class=""></td> 65 <td class=""></td> 66 <td class=""></td> 67 <td class=""></td> 68 <td class=""></td> 69 </tr> 70 <tr> 71 <td></td> 72 <td class ="積地"></td> 73 <td class ="卸地"></td> 74 <td></td> 75 <td></td> 76 <td class ="積地2"></td> 77 <td class ="卸地2"></td> 78 <td></td> 79 <td></td> 80 <td class ="積地3"></td> 81 <td class ="卸地3"></td> 82 <td></td> 83 </tr> 84 </tbody> 85 </c:forEach><%-- ここまで繰り返し処理 --%> 86 </table>
package controllers.dispatch; import java.io.IOException; import java.util.List; import javax.persistence.EntityManager; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import models.Trucks; import utils.DBUtil; @WebServlet("/dispatch/index") public class DispatchIndexServlet extends HttpServlet { private static final long serialVersionUID = 1L; public DispatchIndexServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { EntityManager em = DBUtil.createEntityManager(); List<Trucks> trucks = em.createNamedQuery("getAllTrucks",Trucks.class) .getResultList(); long trucks_count = (long)em.createNamedQuery("getTrucksCount", Long.class) .getSingleResult(); em.close(); request.setAttribute("trucks", trucks); request.setAttribute("trucks_count", trucks_count); if(request.getSession().getAttribute("flush") != null) { request.setAttribute("flush", request.getSession().getAttribute("flush")); request.getSession().removeAttribute("flush"); } RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/views/dispatch/index.jsp"); rd.forward(request, response); } }
Hibernate: create table trucks ( id integer not null auto_increment, office_name varchar(255), sa_time varchar(255), stack_area varchar(255), task_date date, task_time time, task_type varchar(255), truck_code varchar(255), truck_type varchar(255), wa_time varchar(255), wholesale_area varchar(255), primary key (id) ) engine=MyISAM -------------------------------- Hibernate: select trucks0_.id as id1_1_, trucks0_.office_name as office_n2_1_, trucks0_.sa_time as sa_time3_1_, trucks0_.stack_area as stack_ar4_1_, trucks0_.task_date as task_dat5_1_, trucks0_.task_time as task_tim6_1_, trucks0_.task_type as task_typ7_1_, trucks0_.truck_code as truck_co8_1_, trucks0_.truck_type as truck_ty9_1_, trucks0_.wa_time as wa_time10_1_, trucks0_.wholesale_area as wholesa11_1_ from trucks trucks0_ Hibernate: select count(trucks0_.id) as col_0_0_ from trucks trucks0_ Hibernate: insert into trucks (office_name, sa_time, stack_area, task_date, task_time, task_type, truck_code, truck_type, wa_time, wholesale_area) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) Hibernate: select trucks0_.id as id1_1_, trucks0_.office_name as office_n2_1_, trucks0_.sa_time as sa_time3_1_, trucks0_.stack_area as stack_ar4_1_, trucks0_.task_date as task_dat5_1_, trucks0_.task_time as task_tim6_1_, trucks0_.task_type as task_typ7_1_, trucks0_.truck_code as truck_co8_1_, trucks0_.truck_type as truck_ty9_1_, trucks0_.wa_time as wa_time10_1_, trucks0_.wholesale_area as wholesa11_1_ from trucks trucks0_ Hibernate: select count(trucks0_.id) as col_0_0_ from trucks trucks0_
補足情報(FW/ツールのバージョンなど)
Eclipse4.6Neon使用
回答1件
あなたの回答
tips
プレビュー