Spring Boot中yml配置文件Map集合注入及使用方式
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>
-----------------------有任何问题可以在评论区评论,也可以私信我,我看到的话会进行回复,欢迎大家指教------------------------
(蓝奏云官网如果有地址失效了,可以私信我,后续看到会补充)

浙公网安备 33010602011771号