JaveDeveloper
JaveDeveloper

Reputation: 133

<option> returning emptyin UI form:select of spring mvc3

I've a list of values to be passed from my controller to the jsp page. I've the below controller:

@RequestMapping(value="/addClient.do", method = RequestMethod.GET)
protected ModelAndView Submit(HttpServletRequest request, HttpServletResponse response) throws Exception {

    MyForm = new MyForm();


    MyForm.setClientList(MyService.getClientList(/*"30-JUN-15"*/));

    System.out.println("Size of list : "+MyForm.getClientList().size()); //-- Displayed as 10 which is correct

    ModelAndView model = new ModelAndView("feeMaintenance");
    model.addObject("clientForm",MyForm);
    model.addObject("selectedMenu", "MenuSelected");
    model.addObject("clientsList",MyForm.getClientList());
    return model;
}

And my jsp form is as below:

<body>
<form:form method="post" modelAttribute="clientForm" action="${userActionUrl}">
<tr>    <td align="left">
         <form:select path="clientList">  
            <form:option value="-" label="------Select Client ------">  
            <form:options items="${clientsLists}">  
        </form:options></form:option></form:select>  

</tr>   </td>
</form>
</body>

I've removed the additional unrelated code. The drop down only shows ----Select Client--- even though the controller shows the correct values of the clientList. Unable to figure out whats missing.

Upvotes: 0

Views: 50

Answers (2)

sanjay
sanjay

Reputation: 437

try this code. model.addObject("country", projectservice.getallCountry());

**Note:**itemLabel name is same as property name into pojo class and also itemValue name.

Upvotes: 0

sanjay
sanjay

Reputation: 437

if MyForm.getClientList() is successfully return list of client data than rewrite this line into jsp page. you write key name into controller is clientsList and you write this into jsp page is clientsLists this is wrong. I hope this is work.

Upvotes: 2

Related Questions