问题描述
在使用springmvc的时候,遇到一个非常痛苦的问题:Failedtoconvertpropertyvalueoftypejava.lang.Stringtorequiredtypejava.lang.Integerforpropertyorder;nestedexceptionisjava.lang.NumberFormatException:Forinputstring:"sadfas"errors.requiredgoogle了一大把,也照别人说的做了,添加protectedvoidinitBinder(HttpServletRequestrequest,ServletRequestDataBinderbinder)throwsException{binder.registerCustomEditor(Integer.class,null,newIntegerPropertiesEditor());super.initBinder(request,binder);}IntegerPropertiesEditor是我自定义的,行不通,不自定义的也行不通,binder.registerCustomEditor(Integer.class,null,newCustomNumberEditor(Integer.class,true));这到底是怎么回事!
时间: 2024-08-02 00:08:41