Similarly, you ask why Spring does not support a generic template type, such as item [], you can also ask why your collection is not ordered according to the order of the elements displayed by your form. Keep in mind: java.util.List is an ordered collection, so you should tell Spring where every item in the list should be inserted.
Bypass
option 1ΒΊ
Create an AutoPopulatingList as follows
private List<Item> items = new AutoPopulatingList( new ElementFactory() { public Object createElement(int index) throws ElementInstantiationException { items.removeAll(Collections.singletonList(null)); return new Item(); } });
option 2ΒΊ
Since Spring is open source, you can create a custom BeanWrapperImpl . Behind the scenes, BeanWrapperImpl is responsible for filling out your bean. Then compile your own Spring MVC
source share