Home>

I want to search with dynamic SQL from this screen.
You can not get it if you put a date.

<html xmlns: th = "http://www.thymeleaf.org">
<head>
<meta charset = "UTF-8" />
<title>Diary search</title>
</head>
 Diary search 
<form th: action = "@ {/ teacher-nissi-list}" th: object = "${insertMogipuroForm}" method = "post">
<table>
<tr>
<td>Children ID</td>
<td><input type = "text" th: field = "${insertMogipuroForm.searchid}" maxlength = "5" /></td>
</tr>
<tr>
<td>Date</td>
<td>
<input type = "text" th: field = "* {searchstartyear}" />year
<input type = "text" th: field = "* {searchstartmonth}" />month
<input type = "text" th: field = "* {searchstartday}" />days ~
<input type = "text" th: field = "* {searchendyear}" />year
<input type = "text" th: field = "* {searchendmonth}" />month
<input type = "text" th: field = "* {searchendday}" />days
</td>
</tr>
<tr>
</tr></table>
<input type = "submit" name = "nissi_btn" value = "diary search" />
<input type = "submit" name = "usagi_btn" value = "return to the rabbit group class" />
<input type = "submit" name = "zou_btn" value = "return to the elephant class" />
</form>
</html>
<! DOCTYPE html>
<html xmlns: th = "http://www.thymeleaf.org">
<head>
<meta charset = "UTF-8" />
<title>Check diary registration</title>
</head>
 Dialog registration confirmation 
</head><body>
     Diary list 
    <table border = "1">
        <tr>
            <th>id</th>
            <th>Child number</th>
            <th colspan = "3">Children's name</th>
            <th>Sleep start time</th>
            <th>Sleep end time</th>
            <th>Moody</th>
            <th>Defecation</th>
            <th>meal</th>
            <th>One day</th>
            <th>Pick-up time</th>
            <th>Communications</th>
            <th>entry</th>
            <th>Date</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 = "diary registration" />
            <input type = "submit" name = "nissi_btn" value = "return" />
            </form>
</html>
// From the diary search screen to the search list screen
    @RequestMapping (value = "/ teacher-nissi-list", params = "nissi_btn")public String teacherNissiiList (@ModelAttribute ("InsertMogiruroForm") InsertMogipuroForm form, Model model) {
        // Instantiate domain class for data search *
        MogipuroInfo searchNissiInfo = new MogipuroInfo ();
        // Copy form class value to domain class
        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";
        // Set the value value! ! !
        searchNissiInfo.setStartwritedate (startwritedate);
        searchNissiInfo.setEndwritedate (endwritedate);
        // Service processing call to perform search/search
        List<MogipuroInfo>teacherNissilist = service.searchNissiInfo (searchNissiInfo);
        // Store search results in Model object
        model.addAttribute ("teacherNissilist", teacherNissilist);
        return "db/teacherNissilist";
    }
package com.example.web.db;

<select 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>


! = '' ">

  • Answer # 1

    It's written in teacherNissiiList

    String startwritedate = "searchstartyear" + "searchstartmonth" + "searchstartday";
    String endwritedate = "searchendyear" + "searchendmonth" + "searchendday";

    just connects strings, so

    The value of startwritedate is just "searchstartyearsearchstartmonthsearchstartday".

    I don't know the correct type because the implementation of InsertMogipuroForm isn't written, but if you just want to connect the input items,

    String startwritedate = form.getSearchendmonth () + form.getSearchstartday () + form.getSearchstartday ();

    I'm fine.