<form:select class="form-control" path="batch_id" id="genderOptions">
<%for(BatchModel qt:batchlist){%>
<form:option value='<%=qt!=null?qt.getBatch_id():""%>' <%=studlist.getStud_id()!=0?studlist.getBatch_id().getBatch_id()==qt.getBatch_id()?"selected='selected'":"":"" %>/><%=qt.getBname()!=null?qt.getBname():"" %>
<form:errors path="batch_id" cssClass="error" />
<%-- <option value="<%=(String.valueOf(qt.getBatch_id())!=null)?qt.getBatch_id():""%>"><%=(String.valueOf(qt.getBname())!=null)?qt.getBname():""%></option>
--%>
<% } %>
</form:select>
在代码中,您错误地关闭了<form:option/>
标记。像这样关闭它:
<form:select path="country">
<form:option value="NONE" label="--- Select ---"/>
<form:options items="${countryList}" />
</form:select>
通过提供用于设置selected
属性标记的表达式,您没有正确关闭 .尝试使用表达式提供selected
值,就像您为value
属性所做的那样。喜欢:
selected="<%=studlist.getStud_id()!=0?studlist.getBatch_id().getBatch_id()==qt.getBatch_id()?"selected":"":"" %>"