Spring mvc form:select path是model属性中的自定义映射

时间:2015-07-14 09:55:16

标签: spring-mvc hashmap

如何绑定模型的map属性并将选定的值发送回控制器?

我可以填充下拉菜单但是在提交表单时收到错误400 - 错误的请求。

MyModel.java:

public class MyModel{
    private Map<MySubModel, String> subModel = new HashMap<MySubModel, String>();
    private SubModel subModelSearched;
}

SubModel.java:

public class SubModel{
    public String id;
    public String name;
}

JSP:

<form:form action="/mySearch" modelAttribute="myModel" method="post">
    <form:select path="subModelSearched">
        <form:options items="${myModel.subModel}/>
    </form:select>
.....
</form:form>

0 个答案:

没有答案