Reputation: 5
Here is my simple test class (command object class)
public class Test {
private List<MyEnum> list;
//setters and getters
}
and here is the part od JSP page:
<form:form ......>
<form:select multiple="true" path="list" items="enumvalues">
</form:form>
I would like to bind all selected items from jsp list to my command object list. What is the best way to do this? I know, that I need to write some custom editors but after some tests I have no idea how to achieve that.
I would be grateful for any help.
Upvotes: 0
Views: 5083
Reputation: 28005
If you have proper access to list
in JSP, this should work:
<form:form ...>
<form:select multiple="true" path="list">
<form:options />
</form:select>
</form:form>
P.S. If you want options
have different readable name than value, just override enum value's toString()
and Spring MVC will magically use it as description.
Upvotes: 1