We can populate spring select box based on the dynamic values from back-end as like below .There should be one default value which is not in the list, ie Select Country
<form:select path="country"> <form:option value="NONE" label="Select Country"/> <form:options items="${countryList}" /> </form:select>
Now we have the value of country country code or id and based on the value selected values needs to be displayed.When we return the control to the particular page make sure that object bound to that page has proper values set for the variable defined in path attribute.
Lets take the example below
Lets take the example below
<form:select path="countryCode"> <form:options items="${countryList}" itemLabel=countryName itemValue=countryCode/> </form:select>
We just need to populate the country code which needs to selected along with country list in object bound to that page,Rest everything is taken care by spring
0 Comments
Post a Comment