![](/img/trans.png)
[英]How to fetch parameters from the application.properties file for a test case
[英]How to store array of values in application.properties file and fetch it to display them in a thyme leaf template
我想在應用程序屬性文件中存儲血型列表,以便在要求用戶選擇血型時可以將其獲取並顯示在下拉列表中。 我正在使用百里香葉模板引擎。 我想用它來盡可能避免硬編碼(用於學習經驗)。 有任何想法嗎?
血型=A+,B+,AB+
@Value("${bloodGroups}") private String[] bloodGroups;
model.addAttribute("bloodGroups", bloodGroups);
<select required="true" name="bloodGroup" id="bloodGroup"> <option th:selected/> <option th:each="bloodGroup: ${bloodGroups}" th:value="${bloodGroup}" th:text="${bloodGroup}"></option> </select>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.