teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

質問追記

2019/07/30 05:04

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -56,8 +56,6 @@
56
56
  <th>No.</th>
57
57
  <th>列1</th>
58
58
  </tr>
59
-
60
-
61
59
  <tr th:each="strength : ${strength}">
62
60
  <td align="left" th:text="${strength.st_id}"></td>
63
61
  <td align="left">
@@ -67,7 +65,6 @@
67
65
  th:value="${strength.st_id}"
68
66
  th:selected="${strength.st_id == st_id}"
69
67
  th:inline="text">[[${strength.strength}]]
70
-
71
68
  </option>
72
69
  </select>
73
70
  </div>
@@ -83,6 +80,44 @@
83
80
  th:selected="${strength.st_id == st_id}"のように設定しても
84
81
  テーブルの先頭の値が初期値になってしまいます。
85
82
  ![イメージ説明](bae9c8727fcf40208ad8a9964eeb89b0.png)
83
+
84
+ ご指摘のとおり重複IDを下記のとおり変更したところDBの初期値を表示させることが出来ました。
85
+ ```html
86
+ <!DOCTYPE html>
87
+ <html xmlns:th="http://www.thymeleaf.org">
88
+ <head>
89
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
90
+ <title>test</title>
91
+ <link rel="stylesheet" type="text/css" href="master.css" />
92
+ </head>
93
+ <body>
94
+ <table id="t_strength"
95
+ class="table table-striped table-bordered table-hover table-condensed">
96
+ <tr>
97
+ <th>No.</th>
98
+ <th>列1</th>
99
+ </tr>
100
+ <tr th:each="strength : ${strength}">
101
+ <td align="left" th:text="${strength.st_id}"></td>
102
+ <td align="left">
103
+ <div>
104
+ <select id="st_Id" name="Strength">
105
+ <option th:each="Strength : ${st_id}" th:value="${strength.st_id}"
106
+ th:selected="${strength.st_id == st_Id}" th:inline="text">[[${strength.strength}]]
107
+ </option>
108
+ </select>
109
+ </div>
110
+ </td>
111
+ </tr>
112
+ </table>
113
+ </body>
114
+ </html>
115
+ ```
116
+ しかし、ドロップダウンすると以下のようにその値一色(リスト内が同じ値)になってしまいます。
117
+ ![イメージ説明](4bb144673183283f76a2ea921daf6729.png)
118
+ 表示(初期値)は現在のDBの値とするけれど、変更可能なようにドロップダウン自体リスト表示は可能でしょうか?
119
+
120
+
86
121
  ### 補足情報(FW/ツールのバージョンなど)
87
122
  java spring boot
88
123
  IDE:eclipse 2019-06