M
M
Mekan2018-07-12 08:23:03
Spring
Mekan, 2018-07-12 08:23:03

How to accept drop-down data in Thymeleaf?

this is my code :
- View:

<select id="LoanPeriod" name="LoanPeriod">
<option th:each="loanPeriod: ${loanPeriods}"
 th:text="${loanPeriod}"></option>
</select>

-Controller:
List<String> loanPeriods = new ArrayList<String>();
loanPeriods.add("6 months");
loanPeriods.add("9 months");
loanPeriods.add("12 months");
loanPeriods.add("24 months");
model.addAttribute("loanPeriods", loanPeriods);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question