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>

 

 

 

 







免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM