spring mvc - Using HashMap in dropdown list in Thymeleaf -


in controller setting hashmap

@modelattribute("clientimpmap") public map<string,string> populateclientimpmap() throws malformedurlexception, ioexception  {      map<string,string> clientimpmap = new hashmap<string,string> ();     clientimpmap.put("1","high");     clientimpmap.put("2","low");     return clientimpmap; } 

now want populate hashmap using thymeleaf tags .how it? using core spring-mvc tags can this

<td>client importance :</td>     <td><form:select path="personbean.clientimpref">             <form:option value="none" label="--- select ---" />             <form:options items="${clientimpmap}"  />         </form:select></td>     <td><form:errors path="personbean.clientimpref" cssclass="error" /></td> </tr> 

what equivalent of in thymeleaf?

the following code corresponds jsp spring tags have posted in question.

<form action="your-controller-mapping" th:object="${personbean}">    <select th:field="*{clientimpref}">       <option value="none">----select----</option>       <option th:each="entry : ${clientimpmap.entryset()}" th:value="${entry.key}" th:text="${entry.value}">         replaced - used natural templating       </option>    </select> </form> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -