<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Spring-MVCデータモデルの入力チェックサンプル</title>
<meta charset="UTF-8" />
</head>
<body>
<form action="./promenaderes" method="post">
<table th:object="${PromenadeFormData}">
<tr>
<td>
あなたのお名前は? <input type="text" th:field="*{myname}" size="40" maxlength="40"/>
<span style="color:red;" th:if="${#fields.hasErrors('myname')}" th:errors="*{myname}">おいらは、すぷりんぐ太郎たじょ</span>
</td>
</tr>
<tr>
<td>
あなたの年齢は? <input type="text" th:field="*{age}" size="10" maxlength="3"/>
<span style="color:red;" th:if="${#fields.hasErrors('age')}" th:errors="*{age}">教えてあげない</span>
</td>
</tr>
<tr>
<td>
あなたの電話番号は? <input type="text" th:field="*{phone}" size="40" />
<span style="color:red;" th:if="${#fields.hasErrors('phone')}" th:errors="*{phone}">教えてあげない</span>
</td>
</tr>
<tr>
<td>
あなたのemailは? <input type="text" th:field="*{email}" size="60" />
<span style="color:red;" th:if="${#fields.hasErrors('email')}" th:errors="*{email}">email</span>
</td>
</tr>
<tr>
<td>
どれか好きなの選んでね?
<input type="radio" th:field="*{checkVals}" value="酒"/>酒
<input type="radio" th:field="*{checkVals}" value="博打"/>博打
<input type="radio" th:field="*{checkVals}" value="女"/>女
<span style="color:red;" th:if="${#fields.hasErrors('checkValsSelect')}" th:errors="*{checkValsSelect}">どれか選ばんか~ぃ!</span>
</td>
</tr>
<tr>
<td>
<input type="submit" value="回答しちゃるけん" />
</td>
</tr>
</table>
</form>
</body>
</html>
|