What is way to select enum from database? I have:
<select name="country">
<c:forEach items="${countries}" var="value">
<option value="${value}">${value}</option>
</c:forEach>
</select>
I have in class and table 'User' field string/varchar 'country'
Use the option and options tags from the spring forms tld.
If I understand it correctly, you will have to add YourEnum.values()
to the model, say as "enumValues" (according to comments below, this is not necessary).
<form:select path="foo">
<form:option value="-" label="--Please Select"/>
<form:options items="${enumValues}" />
</form:select>
Reference:
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