Is there any way to mark an option as selected by default, much like the selected
attribute in the HTML option
tag like <option value="value1" selected>
?
If the path value of the tag matches the value of options value it will automatically be selected. You don't need anything special
Is there any way to mark an option as selected by default ???
Just use <spring:option Taglib The first one will be automatically selected
<spring:select name="someProperty">
<spring:option value="">Select one</spring:option>
<spring:option value="someValue">Some value<spring:select>
<!--And so on...-->
<spring:select>
or
<spring:select name="someCollection">
<spring:option value="">Select one</spring:option>
<!--Here goes some List added to request-->
<spring:options itemLabel="propertyNameUsedAsLabel" itemValue="propertyNameUsedAsValue"/>
<!--And so on...-->
<spring: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