質問編集履歴

1

情報の追加

2020/02/23 00:59

投稿

encho
encho

スコア182

test CHANGED
File without changes
test CHANGED
@@ -170,6 +170,108 @@
170
170
 
171
171
  ```
172
172
 
173
+ ```html
174
+
175
+ <!DOCTYPE html>
176
+
177
+ <html xmlns:th="http://www.thymeleaf.org">
178
+
179
+ <head>
180
+
181
+ <meta charset="UTF-8" />
182
+
183
+ <title>ユーザー登録</title>
184
+
185
+ <style>
186
+
187
+ .err {
188
+
189
+ color: red;
190
+
191
+ }
192
+
193
+ </style>
194
+
195
+ </head>
196
+
197
+ <body>
198
+
199
+ <div>
200
+
201
+ <h1>ユーザー登録</h1>
202
+
203
+ <table>
204
+
205
+ <form th:action="@{/account}" action="/account" th:object="${accountForm}" method="post">
206
+
207
+ <tr><td><label for="userName">ユーザ名:</label></td>
208
+
209
+ <td><input type="text" name="userName" th:field="*{userName}" th:errorclass="err"/>
210
+
211
+ <div th:if="${#fields.hasErrors('userName')}" th:errors="*{userName}" th:errorclass="err">
212
+
213
+ </div>
214
+
215
+ </td>
216
+
217
+ </tr>
218
+
219
+ <tr>
220
+
221
+ <td><label for="mailAddress">メールアドレス</label></td>
222
+
223
+ <td><input type="text" name="mailAddress" th:field="*{mailAddress}" th:errorclass="err"/>
224
+
225
+ <div th:if="${#fields.hasErrors('mailAddress')}" th:errors="*{mailAddress}" th:errorclass="err">
226
+
227
+ </div>
228
+
229
+ </td>
230
+
231
+ </tr>
232
+
233
+ <tr>
234
+
235
+ <td><label for="password">パスワード</label></td>
236
+
237
+ <td><input type="password" name="password" th:field="*{password}" th:errorclass="err"/>
238
+
239
+ <div th:if="${#fields.hasErrors('password')}" th:errors="*{password}" th:errorclass="err">
240
+
241
+ </div>
242
+
243
+ </td>
244
+
245
+ </tr>
246
+
247
+ <tr>
248
+
249
+ <td><label for="confirmPassword">パスワード(確認)</label></td>
250
+
251
+ <td><input type="password" name="confirmPassword" th:field="*{confirmPassword}" th:errorclass="err"/>
252
+
253
+ <div th:if="${#fields.hasErrors('confirmPassword')}" th:errors="*{confirmPassword}" th:errorclass="err">
254
+
255
+ </div>
256
+
257
+ </td>
258
+
259
+ </tr>
260
+
261
+ <tr><td></td><td><input type="submit" value="新規登録" /></td></tr>
262
+
263
+ </form>
264
+
265
+ </table>
266
+
267
+ </div>
268
+
269
+ </body>
270
+
271
+ </html>
272
+
273
+ ```
274
+
173
275
 
174
276
 
175
277
  以上のようにそれぞれのバリデーション に対するメッセージをグループ化して