この画面から動的SQLで検索したいのですが、
どうしても日付を入れると取得できません。
<html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8" /> <title>日誌検索</title> </head> <h1>日誌検索</h1> <form th:action="@{/teacher-nissi-list}" th:object="${insertMogipuroForm}" method="post"> <table> <tr> <td>園児ID</td> <td><input type="text" th:field="${insertMogipuroForm.searchid}" maxlength="5" /></td> </tr> <tr> <td>日付</td> <td> <input type="text" th:field="*{searchstartyear}" /> 年 <input type="text" th:field="*{searchstartmonth}" /> 月 <input type="text" th:field="*{searchstartday}" />日 ~ <input type="text" th:field="*{searchendyear}" /> 年 <input type="text" th:field="*{searchendmonth}" /> 月 <input type="text" th:field="*{searchendday}" />日 </td> </tr> <tr> </tr></table> <input type="submit" name="nissi_btn" value="日誌検索" /> <input type="submit" name="usagi_btn" value="うさぎ組クラスへ戻る" /> <input type="submit" name="zou_btn" value="ぞう組クラスへ戻る" /> </form> </html> ``` ``` <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8" /> <title>日誌登録確認</title> </head> <h1>日誌登録確認</h1> </head> <body> <h1 class="text-center table table-hover ">日誌一覧</h1> <table border="1" class="table table-striped "> <tr> <th class="text-center">id</th> <th class="text-center">園児番号</th> <th colspan="3" class="text-center">園児の名前</th> <th class="text-center">睡眠開始時間</th> <th class="text-center">睡眠終了時間</th> <th class="text-center">機嫌</th> <th class="text-center">排便</th> <th class="text-center">食事</th> <th class="text-center">1日の様子</th> <th class="text-center">お迎え時間</th> <th class="text-center">伝達事項</th> <th class="text-center">記入者</th> <th class="text-center">日付</th> </tr> <tr th:each="nissi: ${teacherNissilist}"> <td th:text="${nissi.id}"> <td th:text="${nissi.childrenid}"> <td th:text="${nissi.name}"> <td th:text="${nissi.sleepstarttime}"> <td th:text="${nissi.sleependtime}"> <td th:text="${nissi.mood}"> <td th:text="${nissi.poop}"> <td th:text="${nissi.meal}"> <td th:text="${nissi.phase}"> <td th:text="${nissi.pickuptime}"> <td th:text="${nissi.communication}"> <td th:text="${nissi.daybookwriter}"> <td th:text="${nissi.writedate}"> </td></tr></body> <form th:action="@{/teacher-nissi-end}" th:object="${insertMogipuroForm}" > <input type="submit" name="back_btn" value="日記登録" /> <input type="submit" name="nissi_btn" value="戻る" /> </form> </html> ``` ``` // 日誌検索画面から検索List画面へ★★★ @RequestMapping(value = "/teacher-nissi-list", params = "nissi_btn") public String teacherNissiiList(@ModelAttribute("InsertMogiruroForm") InsertMogipuroForm form, Model model) { // データ検索に利用するドメインクラスのインスタンス化* MogipuroInfo searchNissiInfo = new MogipuroInfo(); // Formクラスの値をドメインクラスにコピー BeanUtils.copyProperties(form, searchNissiInfo); int searchstartyear = Integer.parseInt(form.getSearchendmonth()); int searchstartmonth = Integer.parseInt(form.getSearchstartday()); int searchstartday = Integer.parseInt(form.getSearchstartday()); int searchendyear = Integer.parseInt(form.getSearchendyear()); int searchendmonth = Integer.parseInt(form.getSearchendmonth()); int searchendday = Integer.parseInt(form.getSearchendday()); String startwritedate = "searchstartyear" + "searchstartmonth" + "searchstartday"; String endwritedate = "searchendyear" + "searchendmonth" + "searchendday"; // 値値をセット!!! searchNissiInfo.setStartwritedate(startwritedate); searchNissiInfo.setEndwritedate(endwritedate); // 検索検/検索けnんさくを行うためのサービス処理呼び出し List<MogipuroInfo> teacherNissilist = service.searchNissiInfo(searchNissiInfo); // Modelオブジェクトに検索結果を格納 model.addAttribute("teacherNissilist", teacherNissilist); return "db/teacherNissilist"; } ``` ``` package com.example.web.db; <select id="nissiselect" resultType="com.example.domain.MogipuroInfo"> SELECT * FROM mamadiary <where> <if test="searchid != ''"> childrenid = #{searchid} </if> <if test=" childrenid = #{searchid} </if> <if test="searchid != ''"> childrenid = #{searchid} </if> </where> ORDER BY id </select> ``` ![イメージ説明](800a5c862661258bb79d00a23e8762ca.png)!= ''">
回答1件
あなたの回答
tips
プレビュー