Can someone tell me how to set default value in form:select tag in spring?
I have four auctions. 1) Normal 2) Reverse 3) French 4) Dutch
I am using spring's form:select and form:options tag for the same.
But now the requirement is that Normal should be selected by default.
How do I achieve this?
Thanks
Try this
<form:select path="auction">
<c:forEach items="${auctions}" var="auc" varStatus="status">
<c:choose>
<c:when test="${auc.id eq '1'}">
<option value="${auc.id}" selected="true">${auc.name}</option>
</c:when>
<c:otherwise>
<option value="${auc.id}">${auc.name}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</form:select>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With