我有相当复杂的HTML格式,我试图将其映射到模型。表格包含有关董事会(姓名,日期,所有人等)和项目清单的信息。每个项目也包含一些数据。项目是动态添加/删除的,因此我在发送表单之前使用JS添加索引。这是我表格的一部分:
<div>
<label>Link:</label>
<input type="text" name="items[<index>].link">
<label>JScript:</label>
<select name="items[<index>].javaScript">
<option>disable</option>
<option>enable</option>
</select>
</div>
我使用form的onsubmit函数来更改为适当的值。它适用于我的模型,即Board with items of items:
public class Board
{
private long id;
private User owner;
private String title;
private List<Item> items;
...
}
我想要做的是为List注册自定义编辑器或转换器,因为我需要做一些手动更改。
我已经尝试了
binder.registerCustomEditor(Item.class, "items", new PropertyEditorSupport()
和
binder.registerCustomEditor(List.class, "board.items", new CustomCollectionEditor(List.class)
但它根本不起作用。