src/main/resources/templates/test1/input_confirm.html
L thymeleafでinput typeのvalueを取得して表示する
1 2 3 4 5 6 7 8 9 10 | < form class = "" method = "get" action = "inputcomplete" > < input type = "hidden" name = "name" th:value = "${name}" > < input type = "hidden" name = "department" th:value = "${department}" > < table class = "table" > < tr >< td >名前</ td >< td th:text = "${name}" >狩野 良平</ td ></ tr > < tr >< td >所属</ td >< td th:text = "${department}" >営業部</ td ></ tr > </ table > < button type = "button" class = "btn btn-primary" onclick = "location.href='/test1/input'" >戻る</ button > < button type = "submit" class = "btn btn-primary" >登録完了</ button > </ form > |
MainController.java
L completeもconfirmと基本は同じ、RequestParamで取得する
1 2 3 4 5 6 7 8 9 | @GetMapping ( "inputcomplete" ) public String output2( @RequestParam (name = "name" ) String name, @RequestParam (name = "department" ) String department, Model model) { model.addAttribute( "name" , name); model.addAttribute( "department" , department); return "test1/input_complete" ; } |
src/main/resources/templates/test1/input_complete.html
1 2 3 4 5 6 7 8 9 10 11 12 13 | < link th:href = "@{/css/style.css}" rel = "stylesheet" type = "text/css" > // 省略 < h1 >社員登録 完了</ h1 > < div class = "col-md-8" > < p >社員の登録が完了しました。</ p > < table class = "table" > < tr >< td >名前</ td >< td th:text = "${name}" >狩野 良平</ td ></ tr > < tr >< td >所属</ td >< td th:text = "${department}" >営業部</ td ></ tr > </ table > < button type = "button" class = "btn btn-primary" onclick = "location.href='/index'" >一覧に戻る</ button > </ div > |
GetではなくPostにしたいが、Getなら凄く簡単だということはわかった。
ファイルのルーティングはControllerでやるのね。
で、この入力データをINSERTしたい。