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