The options tag

In this section, you will learn about the options tag of Spring form tag library.

The options tag

The options tag

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>