html、js前台数据传到后台,spring复杂类型转换
如果我有两个变量,变量名不一样,处理的规则也不一样,但是他们都是Date.class 类型, 这可怎么破。比如:
@InitBinder
public void bindingPreparation(WebDataBinder binder) {
DateFormat dateFormat1 = new SimpleDateFormat("d-MM-yyyy");
CustomDateEditor orderDateEditor = new CustomDateEditor(dateFormat1, true);
DateFormat dateFormat2 = new SimpleDateFormat("MMM d, YYYY");
CustomDateEditor shipDateEditor = new CustomDateEditor(dateFormat2, true);
binder.registerCustomEditor(Date.class, "orderDate", orderDateEditor);
binder.registerCustomEditor(Date.class, "shipDate", shipDateEditor);
}
spring中有很多种propertyEditor