开发者

Binding delimited strings in textbox to Collection<String>

开发者 https://www.devze.com 2023-03-07 20:03 出处:网络
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.

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

精彩评论

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