spring mvc - Input to the arraylist with Thymeleaf -


i have simple class contains 2 string,1 integer , 1 arraylist<string>. using spring mvc , thymeleaf i'm trying craete form, can insert data create object. sadly have no idea how handle arraylist. got far:

<!doctype html> <html> <head> <meta charset="utf-8"> <title>insert title here</title> </head> <body>     <h1>f o r m</h1>     <form th:action="@{/form/person}" th:object="${person}" method="post">         <table>             <tr>                 <td>name:</td>                 <td><input type="text" th:field="*{name}" /></td>                 <td th:if="${#fields.haserrors('name')}" th:errors="*{name}">name                     error</td>             </tr>             <tr>                 <td>age:</td>                 <td><input type="number" th:field="*{age} " /></td>                 <td th:if="${#fields.haserrors('age')}" th:errors="*{age}">age                     error</td>             </tr>             <tr>                 <td>city:</td>                 <td><input type="text" th:field="*{city}" /></td>                 <td th:if="${#fields.haserrors('city')}" th:errors="*{city}">city                     error</td>             </tr>             <tr>                 <td><input type="submit" value="submit" /></td>                 <td><input type="reset" value="reset" /></td>             </tr>         </table>     </form> </body> </html> 

for example if list name city then:

 <input type="text" th:field="*{city[__${index}__]}" /> 

where index index in list. when example put string on second index on first index have null.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -