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类型。

解决方案 »

  1.   

    是不是说把command中属性为date类型的值在request取来的时候
    会用这个模式进行格式化呢?那如果是integer类型的呢?另外上面的是没有错的。
    具体你可以看一下roller源码
      

  2.   

    基本类型都有默认的PropertyEditor
    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");
    }
      

  3.   

    晕,requiredType == null && propertyPath == null看成||了,程序在后面也判断了propertyPath是否为空。这样用和 binder.registerCustomEditor(Integer.class,new CustomNumberEditor(Integer.class, null, true))效果是一样的。
      

  4.   

    binder.registerCustomEditor(Integer.class, null,new CustomNumberEditor(Integer.class, null, true));拿这一句来说一下
    是不是说command这个类的所有属性为Integer的成员变量,都是不可以为null的?
    那binder起到什么作用呢?
    谢谢
      

  5.   

    public CustomNumberEditor(Class numberClass, NumberFormat numberFormat, boolean allowEmpty)allowEmpty=true,当request取得的参数为null或空字串时,command类的class为Integer的属性将为null,否则为new Integer(0)