Save
列表:的人对象列表 的OBJ:
Class obj{
Person person;
getter/setters
}
在这JSP,我有当选择特定单选按钮附加的人。
在控制器端
@RequestMapping(value = "/save", method = RequestMethod.POST)
public String postProcess(@ModelAttribute("obj") Obj obj,BindingResult error) {
//processing
return "anotherJsp";
}
@InitBinder
public void initBinder(WebDataBinder binder, Locale locale, HttpServletRequest request) {
binder.registerCustomEditor(Obj.class,"person", new PropertyEditorSupport() {
@Override
public void setAsText(String text) {
//processing for conversion of person object String to Person Object
setValue(text);
}
});
}
我在这里使用initbinder,因为我正从JSP Person对象的字符串...所以我得到的结合异常无法从字符串转换成个人。
当将数据绑定到modelAttribute.Hence时,在initbinder中我会将字符串转换为Person对象之前调用InitBinder。
这里主要的问题是我的InitBinder在Not called/Invoked。 请给我解决方案。
谢谢。