Spring MVC Select Tag Example

Spring mvc select tag can be used in multiple ways. We will see some of the ways in which we can use spring mvc select tag as a dropdown or a multiple select list.

1. Spring MVC select tag as dropdown

We can use <form:option>  or <form:options>

<form:option> tag is generally used when individual items are to be added.

<form:options> tag is generally used when a list is to be passed to the select tag.

2. Spring MVC select tag as multiple select list box

For using select tag as a multi select list , we need to add multiple=”true”

The multiple=”true” is a optional attribute. You can get more details on the other attributes that can be used for

at the Spring Form TLD

Complete Example with Code

1. Create a Model Class

2. Create a Controller
In this example Controller is used to create the data required to show in the dropdown

3. Create a View to show the form

4. Create a success page to show the data selected on form

Execution of Code

Java Spring MVC Tutorial | Spring MVC Select Tag with Example

After selecting some values and clicking the submit button, a success page will be displayed
Spring MVC Select Tag with Example | Java Spring MVC Tutorial

Download the Source Code : – SpringMVC-SelectTagExample.zip

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn