html - Having a form under a For-Each cycle in Thymeleaf -
i new in spring boot , have problem thymeleaf. want use html form under each cycle, receive exception.
this code:
<tr th:each="item : ${users}"> <td th:text="${item.getfirstname()}">first name</td> <td th:text="${item.getlastname()}">last name</td> <td th:text="${item.getemailaddress()}">email address</td> <td th:text="${item.getdateofbirth()}">date of birth</td> <!--<td><a th:href="${'/user/edit/' + user.id}">edit</a></td> --> <td>edit</td> <td> <form th:object="${item}" th:action="@{/delete}" method="post"> <input type="hidden" th:field="*{firstname}"/> <input type="hidden" th:field="*{lastname}"/> <input type="hidden" th:field="*{emailaddress}"/> <input type="hidden" th:field="*{dateofbirth}"/> <input type="submit" value="delete"/> </form> </td> </tr>
and exception receive:
[thymeleaf][http-nio-8080-exec-1] exception processing template "users": error during execution of processor 'org.thymeleaf.spring4.processor.attr.springinputgeneralfieldattrprocessor' (users:31)
can tell me doing wrong?
thank in advance!!!
i use thymeleaf view engine in spring boot app.following example code might idea it.
user model
@entity public class user { @id @generatedvalue(strategy = generationtype.identity) @column(name="id", nullable = false ) private long id; @column(name="user_name" ) private string username; @email(message="email not valid") @column(name="email",nullable=false) private string email; public long getid() { return id; } public void setid(long id) { this.id = id; } public string getusername() { return username; } public void setusername(string username) { this.username = username; } }
user controller
model.addattribute("users", userservice.getallusers());
user view
<tr th:each="user : ${users}"> <td th:text="${user.id}"></td> <td th:text="${user.email}"></td> <td th:text="${user.username}"></td> </tr>
Comments
Post a Comment