jstl+el 獲取枚舉元素

新手筆記:

//枚舉

   public enum AttributeType {
        text, number, alphaint, select, checkbox, date

    }


// 獲取所有商品屬性類型
    public List<AttributeType> getAllAttributeType() {
        List<AttributeType> allAttributeType = new ArrayList<AttributeType>();
        for (AttributeType attributeType : AttributeType.values()) {
            allAttributeType.add(attributeType);
        }
        return allAttributeType;
    }


在jsp頁面上使用jstl

<select id="productAttributeType" name="productAttribute.attributeType" >
                            <option value="">請選擇...</option>                                              
                            <c:forEach items="${allAttributeType}" var="list">
                                <option value="list">
                                    ${list}
                                </option>
                            </c:forEach>
 </select>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章