package com.msun.mms.adapter;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
/**
* 解决从前台页面到后台控制层实体类注入时,类型转换异常
* 如:String类型转换为Date类型
* @author Administrator
*
*/
public abstract class DataTypeConverterAdapter {
@InitBinder
protected void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
}
解决从前台页面到后台控制层实体类注入时,类型转换异常
最新推荐文章于 2021-02-24 10:19:24 发布