开发者

Spring MVC - bind form elements to a List<Long>

Is it possible to bind a form element to a List<Long>开发者_开发百科?

ie. <form:input path="formValues[0]" /> binding to an element in List<Long> formValues; in the form backing object?

When I try this, it fails because Long does not have a default constructor new Long().

I've worked around it by creating a dummy holder class

class DummyLong {
    private Long value;
    ...
}

making the list in the formbacking object a List<DummyLong> and changing the form tag to <form:input path="formValues[0].value" /> but this seems unnecessarily hideous and I'm sure there must be a better way. Haven't been able to find it though.


Use List<Long> formValues with <form:input path="formValues" />

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜