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
精彩评论