[英]How to fetch an element from arraylist and set it as the class(HTML tag) name?
我在jsp頁面中導入了一個arraylist。 現在,我想獲取arraylist的元素並將其設置為html標簽類。
<div class="<arraylist_item>">
<select name="doctype" class="my_dropdown" style="color:white; background:#655D78">
<option disabled="disabled" selected="selected">Select Doc Type</option>
</select>
</div>
我不確定如何從這里繼續。 任何形式的幫助均不勝感激。 先感謝您。
如果您需要特定數組列表元素中的項,請使用JSP表達式語言,例如<div class="${array.get(specific_index).toString()}"/>
如果需要遍歷數組列表並為列表的每個元素創建元素,則可以使用JSTL中的forEach標記。 例如
<c:forEach var="item" items="${array}">
<div class="${item.toString()}"/>
</c:forEach>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.