binder.registerCustomEditor(Integer.class, null,new CustomNumberEditor(Integer.class, null, true));
第2个参数为Command类的field名字,不能为null的。
new CustomNumberEditor(Integer.class, null, true)
也错了,第2个参数为NumberFormat的实现类,指定了format number的方式,不能为null.binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
表示Command类所有为Date的属性都由指定的CustomDateEditor来格式化表单字串成为Date类型。
第2个参数为Command类的field名字,不能为null的。
new CustomNumberEditor(Integer.class, null, true)
也错了,第2个参数为NumberFormat的实现类,指定了format number的方式,不能为null.binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
表示Command类所有为Date的属性都由指定的CustomDateEditor来格式化表单字串成为Date类型。
会用这个模式进行格式化呢?那如果是integer类型的呢?另外上面的是没有错的。
具体你可以看一下roller源码
integer,double等对应的是CustomNumberEditorroller是虾米?看Spring的源码就够了,look: public void registerCustomEditor(Class requiredType, String propertyPath, PropertyEditor propertyEditor) {
if (requiredType == null && propertyPath == null) {
throw new IllegalArgumentException("Either requiredType or propertyPath is required");
}
是不是说command这个类的所有属性为Integer的成员变量,都是不可以为null的?
那binder起到什么作用呢?
谢谢