<select name="category" class="select1" id="category">
<c:forEach items="${itemCategoryList}" var="ic">
<c:set var="selectedString" value=""/>
<c:if test="${ic.id eq item.itemCategory.id}">
<c:set var="selectedString" value="selected"/>
</c:if>
<option value="${ic.id }" ${selectedString }>${ic.name }</option>
</c:forEach>
</select>
jsp页面中的java代码实现默认选中
<select name="clientLevel" class="select1" id="clientLevel">
<%
for (Iterator<ClientLevel> iter = clientLevelList.iterator(); iter.hasNext();) {
ClientLevel cl = iter.next();
String selectedString = "";
if (cl.getId().equals(client.getClientLevel().getId())) {
selectedString = "selected";
}
%>
<option value="<%=cl.getId() %>" <%=selectedString %>><%=cl.getName() %></option>
<%
}
%>
</select>
用jstl解决默认选中
最新推荐文章于 2021-08-26 14:38:39 发布