开发者

Binding delimited strings in textbox to Collection<String>

I have an <form:input type="text" /> element that can take several values, each delimited by a semicolon. For example, it can take a value such as Mike;Jack;Bob.

H开发者_Go百科ow can I bind/pass this type of value for an <input> to a Collection<String> in Spring 3 MVC?


You can register a property editor:

@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(Collection.class, 
          new DelimitedCollectionStringEditor());
}

where the editor must extend PropertyEditorSupport

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜