在我的Spring3.1.2应用程序中,我有一个带有对象列表的表单,这些对象将在表单中呈现为一个表。我希望将属性编辑器绑定到列表的一个字段,并且还有许多其他字段共享该类型。
我尝试使用registerCustomEditor(Class, String, PropertyEditor)方法进行绑定,但它不起作用。我可以绑定到所有包含该类的字段,但这不符合我的需要。我尝试使用fieldName和*.fieldName作为参数。如何绑定列表中对象的所有字段?
发布于 2013-02-02 04:13:11
我在InitBinder中编写了一些技巧来查找所有合适的属性,并将PropertyEditor添加到每个属性中:
@InitBinder("detailForm")
protected void initBinder(WebDataBinder binder, WebRequest request) throws Exception {
for (String param : request.getParameterMap().keySet()){
if (param.endsWith("currencyAmount")){
binder.registerCustomEditor(BigDecimal.class, param, new CurrencyPropertyEditor());
}
}
}https://stackoverflow.com/questions/14650253
复制相似问题