3
我有一個<form:input type="text" />
元素,它可能需要幾個值,每個值都用分號分隔。例如,它可能需要一個值,如Mike;Jack;Bob
。將文本框中的分隔字符串綁定到集合<String>
如何在Spring 3 MVC中將<input>
的這種類型的值綁定到Collection<String>
?
我有一個<form:input type="text" />
元素,它可能需要幾個值,每個值都用分號分隔。例如,它可能需要一個值,如Mike;Jack;Bob
。將文本框中的分隔字符串綁定到集合<String>
如何在Spring 3 MVC中將<input>
的這種類型的值綁定到Collection<String>
?
您可以註冊一個屬性編輯器:
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(Collection.class,
new DelimitedCollectionStringEditor());
}
在編輯器必須擴展PropertyEditorSupport