Spring 3 Collection Binding

时间:2009-11-05 16:41:08

标签: java jsp spring-mvc

如何将集合绑定到inputdata的表单(不用于show)

2 个答案:

答案 0 :(得分:2)

e.g。对于Set<Jokers>

protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
    binder.registerCustomEditor(
        Set.class,
        "[nameOfTheClassMemberItShouldGoto]",
        new CustomCollectionEditor(Set.class) {
            protected Object convertElement(Object element) {
                return (element == null ? null : getQueryService().getJoker(element.toString()));
            }
        }
    );
}

或类似于此

答案 1 :(得分:0)

我做了同样的问题并得到了一个很好的解决方案,请看一下How to bind a list of object to SpringMvc Controller?