Student sutdent = new Student(); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(sutdent);
//自定义类型转换 参数1属性类型 参数2转换方法 bw.registerCustomEditor(LocalDate.class, new PropertyEditorSupport(){ @Override public void setAsText(String dateStr) throws IllegalArgumentException { this.setValue(LocalDate.parse(dateStr)); } }); bw.setPropertyValue("date", "2020-01-01");