Search code examples
jspdrop-down-menudefault-valueitems

How can I retrieve the default value for my jsp dropdown item list?


In my JSP page, I'm utilising a Dropdownlist. Table provides the values.

My issue is that the first option in the list is displayed as the dropdown list's default value.

When the page loads, I want (—None—) to be the default setting. What is the best way to achieve this?

Here's where I put my code:

<div class="form-group">
            <form:label path="Id">Forms:</form:label>
            <form:select path="Id" class="form-control"  items="${forms}" itemValue="id" itemLabel="name"/>
</div>

Solution

  • It worked

           <form:select path="templateId" class="form-control">
               <form:option value="-1" label="None"/>
               <form:options items="${temps}" itemValue="id" itemLabel="name"/>
             </form:select>