前提・実現したいこと
現在、条件分岐を使って、<th>に表示されている連続した日付と、formからDBに送られたn月m日の出発点・到着点、時刻などを
一致する日付の行に車両のその日の情報を表示という機能を実装したいのですが、
自分でやってみたところ、
<c:if>を使って一致するものを表示という形を取ろうと思ったのですが、エラーになってしまったのでヒントを頂きたいです。
発生している問題・エラーメッセージ
HTTPステータス 500 - An exception occurred processing JSP page /WEB-INF/views/dispatch/index.jsp at line 38 type 例外レポート メッセージ An exception occurred processing JSP page /WEB-INF/views/dispatch/index.jsp at line 38 説明 The server encountered an internal error that prevented it from fulfilling this request. 例外 org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/dispatch/index.jsp at line 38 35: session.setAttribute("1月","日"); 36: %> 37: 38: <c:if test="${truck.task_date == '1月'+stts.count+'日'}" var="flg"/> 39: <c:forEach var="truck" items="${trucks}" varStatus="status"> 40: <tbody> 41: <c:if test="${flg}"> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:579) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) controllers.dispatch.DispatchIndexServlet.doGet(DispatchIndexServlet.java:49) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) filters.LoginFilter.doFilter(LoginFilter.java:72) filters.EncodingFilter.doFilter(EncodingFilter.java:38) 原因 java.lang.NumberFormatException: For input string: "1月" java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) java.lang.Long.parseLong(Long.java:589) java.lang.Long.valueOf(Long.java:803) org.apache.el.lang.ELArithmetic$LongDelegate.coerce(ELArithmetic.java:212) org.apache.el.lang.ELArithmetic.coerce(ELArithmetic.java:384) org.apache.el.lang.ELArithmetic.add(ELArithmetic.java:257) org.apache.el.parser.AstPlus.getValue(AstPlus.java:40) org.apache.el.parser.AstPlus.getValue(AstPlus.java:38) org.apache.el.parser.AstEqual.getValue(AstEqual.java:38) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:943) org.apache.jsp.WEB_002dINF.views.dispatch.index_jsp._jspx_meth_c_005fif_005f1(index_jsp.java:537) org.apache.jsp.WEB_002dINF.views.dispatch.index_jsp._jspService(index_jsp.java:221) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) controllers.dispatch.DispatchIndexServlet.doGet(DispatchIndexServlet.java:49) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) filters.LoginFilter.doFilter(LoginFilter.java:72) filters.EncodingFilter.doFilter(EncodingFilter.java:38)
該当のソースコード
JSP
1 <table class="Truck_table"> 2 <thead> 3 <tr> 4 <th class="space1" rowspan="2" colspan="4"></th> 5<c:forEach begin="1" end="31" varStatus="stts"> 6 <th class="date" colspan="4">1月<c:out value="${stts.count}"></c:out>日</th></c:forEach> 7 </tr> 8 <tr> 9 <c:forEach begin="1" end="31"> 10 <th class="task_type">宵積卸地</th> 11 <th class="task_type">積地</th> 12 <th class="task_type">卸地</th> 13 <th class="task_type">宵積</th> 14 </c:forEach> 15 </tr> 16 </thead> 17 <% 18 session.setAttribute("1月","日"); 19 %> 20 21 <c:if test="${truck.task_date == '1月'+stts.count+'日'}" var="flg"/> 22 <c:forEach var="truck" items="${trucks}" varStatus="status"> 23 <tbody> 24 <c:if test="${flg}"> 25 <tr> 26 <td class="office_name" rowspan="4"><c:out value="${truck.office_name}"></c:out></td> 27 <td class ="truck_code" colspan="2" rowspan="4"><c:out value="${truck.truck_code}"></c:out></td> 28 <td class ="truck_type" rowspan="4"><c:out value="${truck.truck_type}"></c:out></td> 29 30 <td class ="time"><c:out value="${truck.mw_time}"></c:out></td> 31 <td class ="time"><c:out value="${truck.sa_time}"></c:out></td> 32 <td class ="time"><c:out value="${truck.wa_time}"></c:out></td> 33 <td class ="time"><c:out value="${truck.es_time}"></c:out></td> 34 </tr> 35 36 <tr> 37 <td class ="area" id="1"><c:out value="${truck.m_wholesale_area}"></c:out></td> 38 <td class ="area" id="1"><c:out value="${truck.stack_area}"></c:out></td> 39 <td class ="area" id="1"><c:out value="${truck.wholesale_area}"></c:out></td> 40 <td class ="area" id="1"><c:out value="${truck.e_stack_area}"></c:out></td> 41 </tr> 42 43 <tr> 44 <td class ="area" id="2"><c:out value="${truck.m_wholesale_area}"></c:out></td> 45 <td class ="area" id="2"><c:out value="${truck.stack_area}"></c:out></td> 46 <td class ="area" id="2"><c:out value="${truck.wholesale_area}"></c:out></td> 47 <td class ="area" id="2"><c:out value="${truck.e_stack_area}"></c:out></td> 48 </tr> 49 50 <tr> 51 <td class ="time"></td> 52 <td class ="time"><c:out value="${truck.sa_time2}"></c:out></td> 53 <td class ="time"><c:out value="${truck.wa_time2}"></c:out></td> 54 <td class ="time"></td> 55 </tr> 56 <tr> 57 <td class ="area" id="3">ボタン</td> 58 <td class ="area" id="3"><c:out value="${truck.stack_area2}"></c:out></td> 59 <td class ="area" id="3"><c:out value="${truck.wholesale_area2}"></c:out></td> 60 <td class ="area" id="3">ボタン</td> 61 </tr> 62 </c:if> 63 </tbody> 64 </c:forEach> 65 </table>
Java
1import java.io.IOException; 2import java.util.List; 3 4import javax.persistence.EntityManager; 5import javax.servlet.RequestDispatcher; 6import javax.servlet.ServletException; 7import javax.servlet.annotation.WebServlet; 8import javax.servlet.http.HttpServlet; 9import javax.servlet.http.HttpServletRequest; 10import javax.servlet.http.HttpServletResponse; 11 12import models.Trucks; 13import utils.DBUtil; 14 15 16@WebServlet("/dispatch/index") 17public class DispatchIndexServlet extends HttpServlet { 18 private static final long serialVersionUID = 1L; 19 20 21 public DispatchIndexServlet() { 22 super(); 23 } 24 25 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 26 EntityManager em = DBUtil.createEntityManager(); 27 28 List<Trucks> trucks = em.createNamedQuery("getAllTrucks",Trucks.class) 29 .getResultList(); 30 31 long trucks_count = (long)em.createNamedQuery("getTrucksCount", Long.class) 32 .getSingleResult(); 33 34 em.close(); 35 36 37 38 39 request.setAttribute("trucks", trucks); 40 request.setAttribute("trucks_count", trucks_count); 41 if(request.getSession().getAttribute("flush") != null) { 42 request.setAttribute("flush", request.getSession().getAttribute("flush")); 43 request.getSession().removeAttribute("flush"); 44 } 45 RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/views/dispatch/index.jsp"); 46 rd.forward(request, response); 47 } 48} 49
補足情報(FW/ツールのバージョンなど)
Eclipse4.6Neon使用、MySQL
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。