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
Related articles
- [python] an error message appears when trying to convert a string of numbers entered in input to a float function
- Spring boot multiple data source dynamic switch code example
- Dynamic update analysis of Spring Cloud Zuul routing rules
- Spring + srpingmvc + hibernate to achieve dynamic ztree generation treemap effect
- Analysis of Spring CGLlB dynamic proxy implementation process
- Detailed implementation of spring boot configuration dynamic refresh
- Spring dynamic proxy implementation code example
- Detailed Spring Boot + Mybatis implementation of dynamic data sources
- Spring AOP manual implementation of simple dynamic proxy code
- Which of the JDK and CGLib dynamic proxies in Spring AOP is more efficient?
- Spring Boot + Mybatis for dynamic data source case analysis
- C # convert value in configuration file appsetting to dynamic object call
Related questions
- java : Thymeleaf template error in production
- java - i would like to know how to implement table join in spring + mybatis
- java - i want to implement a search function in spring
- java - sql error occurs while implementing search function in spring
- java - about error that object cannot refer
- java - spring boot @manytomany related setting method
- java - i want to use thymeleaf and two each for one table
- i want to display/hide a table in html using thymeleaf
- java - about conversion of date type format
- html - fixed phrase disappeared when inserting th:field in
It's written in teacherNissiiList
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.