How to set a selectbox value in jsp from controller.
Employee employee = new Employee();
I created new object for entity Employee and then set the value of designation with this code..
employee.setEmpDesignation(addEmployeeForm.getEmpDesignation());
Here is the jsp
<form:select path="empDesignation" id="emplDesignation" onchange="showTextBox();" cssClass="textBox">
<c:forEach var="desig" items="${designation}">
<option value="${desig.designationDesc}">
<c:out value="${desig.designationDesc}"/>
</option>
</c:forEach>
</form:select>
Basically I am trying to set the values entered by the user,when error occurs.
But it always displays the first value in the selectbox.
Why are you not using
<form:options>
?E.g:
if your form backing object is bound, SpringMVC should handle all this for you.