展示效果:
表结构:
代码: 运用双重循环加判断实现
注:fnc:getCategoryList(1, '', 20, '')是自定义标签实现的方法
<select name="category" id="selectState" style="width: 130px;">
<c:forEach items="${fnc:getCategoryList(1, '', 20, '')}" var="category">
<c:if test="${category.parentId == '1'}">
<optgroup label="${category.name}">
</c:if><c:forEach items="${fnc:getCategoryList(1, '', 20, '')}" var="category1">
<c:if test="${category.id==category1.parentId}">
<option value="${category1.id}" <c:if test="${article.category.id==category1.id}">selected </c:if>>${category1.name}&l