yml配置文件
maps: "{key1: 'value1', key2: 'value2'}"
java中
@Value("#{${maps}}") private LinkedHashMap maps;
我這里之所以用LinkedHashMap類型 是因為我想要是有序的 可以根據自己的來
thymeleaf遍歷
<select class="form-control" name="maps" > <option th:each="item,m:${map}" th:value="${m.current.key}" th:text="${m.current.value}" required></option> </select>