確認画面へ出力できた値をDBへ登録しようとするも、エラーが出てしまいます。
エラー内容
java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_231] at java.lang.Integer.parseInt(Integer.java:592) ~[na:1.8.0_231] at java.lang.Integer.parseInt(Integer.java:615) ~[na:1.8.0_231] at com.example.web.db.MogipuroController.teacherNissiend(MogipuroController.java:165) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.27.jar:9.0.27] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.27.jar:9.0.27] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.27.jar:9.0.27] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.27.jar:9.0.27] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.27.jar:9.0.27] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27] at こ ``` ``` <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8" /> <title>タイムリー確認</title> </head> <body> <h1>登録確認</h1> <p>※ 入力内容を確認してください。</p> <form th:action="@{/insert-ensyu1-end}" th:object="${insertMogipuroForm}" method="post"> <table> <tr> <td>園児ID</td> <td> <span th:text="${insertMogipuroForm.childrenid}" ></span> </td> </tr> <tr> <td>園児氏名</td> <td> <span th:text="${insertMogipuroForm.name}" ></span> </td> </tr> <tr> <td>記入日</td> <td> <span th:text="${insertMogipuroForm.year}"></span>年 </td> <td> <span th:text="${insertMogipuroForm.month}"></span>月 </td> <td> <span th:text="${insertMogipuroForm.day}"></span>日 </td> </tr> <tr> <td>伝達事項</td> <td> <span th:text="${insertMogipuroForm.communication}" ></span> </td> </tr> </table> <input type="submit" name="timely_btn" value="登録する" /> <input type="submit" name="back_btn" value="戻る" /> </form> </html> ``` ``` package com.example.domain; import java.util.List; public class MogipuroInfo { private String timelyid; private String id; private String name; private String classs; private String sleepstarttime; private String sleependtime; private String mood; private String poop; private String meal; private String phase; // 検索けんさくリスト private String searchid; public String serchtimelyid; private String searchstartyear; private String searchstartmonth; private String searchstartday; private String searchendyear; private String searchendmonth; private String searchendday; //保護者の private String pickuptime; private String communication; private String daybookwriter; private String writedate; private String childrenid; private String childrenname; private String timelywriter; private String year; private String month; private String day; private String startmin; private String endmin; private List<String> yearList; private List<String> monthList; private List<String> dayList; private List<String> startTimeList; private List<String> startMinList; private List<String> endTimeList; private List<String> endMinList; private String startwritedate; private String endwritedate; private String writedatetime; private String communicaton; private String starttime; private String endtime; private String theDate; private String startTime1; private String endTime1; public String getTheDate() { return theDate; } ``` ``` } // 日誌登録確認から完了画面へリダイレクト ★DB登録 @RequestMapping(value = "/teacher-nissi-end", params = "nissi_btn") public String teacherNissiend(@ModelAttribute("insertMogipuroForm") InsertMogipuroForm form) { // データ登録に利用するドメインクラスのインスタンス化 MogipuroInfo inputNissiInfo = new MogipuroInfo(); // Formクラスの値をドメインクラスにコピー BeanUtils.copyProperties(form, inputNissiInfo); //登録用・登録用に変換 int year = Integer.parseInt(form.getYear()); int month = Integer.parseInt(form.getMonth()); int day = Integer.parseInt(form.getDay()); String sleepstarttime1 = form.getSleepstarttime1(); String sleependtime1 = form.getSleependtime1(); String sleepstarttime2 = form.getSleepstarttime2(); String sleependtime2 = form.getSleependtime2(); String theDate = String.format("%04d%02d%02d", year, month, day); MogipuroInfo.setTheDate(theDate); MogipuroInfo.setStartTime1(sleepstarttime1 + ":" + sleependtime1); MogipuroInfo.setEndTime1(sleepstarttime2 + ":" + sleependtime2); System.out.print(form.getYear()); // データ登録を行うためのサービス処理呼び出し service.inputNissiInfo(inputNissiInfo); return "redirect:/teacher-nissi-end?finish"; ```
回答1件
あなたの回答
tips
プレビュー