form:选择spring mvc 3返回UI中的空列表 [英] form:select of spring mvc 3 returning empty list in UI

查看:84
本文介绍了form:选择spring mvc 3返回UI中的空列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从控制器传递到jsp页面的值列表。我有以下控制器:



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;
}





我的jsp表格如下:





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>





我删除了其他不相关的代码。下拉列表仅显示---- Select Client ---即使控制器显示clientList的正确值。无法弄清楚什么是丢失的。



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.

推荐答案

{userActionUrl} >
< tr > < span class =code-keyword>< td align = left >
< 表单:选择 path = clientList >
< form:option value = - 标签 = ------选择客户端------ >
< ; form:options items =
{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 > < < span class =code-leadattribute> / td >
< / form >
< / body >
{clientsLists}"> </form:options></form:option></form:select> </tr> </td> </form> </body>





我删除了其他不相关的代码。下拉列表仅显示---- Select Client ---即使控制器显示clientList的正确值。无法弄清楚什么是丢失的。



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.


这篇关于form:选择spring mvc 3返回UI中的空列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆