In this section, you will learn about the options tag of Spring form tag library.
The options tag renders a list of HTML 'option' tags. It sets the 'selected' attribute on the appropriate option based on the bound value.
Sample code is shown below :
<tr>
<td>Country:</td>
<td>
<form:select path="country">
<form:option value="-" label="--Please Select"/>
<form:options items="${countryList}" itemValue="code" itemLabel="name"/>
</form:select>
</td>
</tr>
This will render the following HTML :
<tr> <td>State:</td> <td> <select name="state"> <option value="-" >--Please Select</option> <option value="UP">Uttar Pradesh</option> <option value="MP">Madhya Pradesh</option> <option value="AP">Arunachal Pradesh</option> <option value="HP">Himachal Pradesh</option> </select> </td> </tr>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: The options tag
Post your Comment