How to set default value for form: select tag in spring

Can someone tell me how to set the default value in the form: select tag in spring?

I have four auctions. 1) Normal 2) Reverse 3) French 4) Dutch

I use spring form: select and form: parameter tag for the same.

But now the requirement is that Normal should be selected by default.

How do I achieve this?

thanks

+4
source share
2 answers

try it

<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> 
+8
source

Source: https://habr.com/ru/post/1339336/