package cn.tz.action.abs;
import java.text.SimpleDateFormat;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
/**
* 专门抽取action中公有的属性或方法
* @author admin
*
*/
public abstract class AbstractAction {
/**
* 用来转换日期格式的
* @param binder
*/
@InitBinder
public void initBinder(WebDataBinder binder){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//本方法的处理指的是追加一个自定义的转换编辑器,如果遇见的操作目标类型为java.util.Date类
//则使用定义好的SimpleDateFormat类来进行格式化处理,并且允许此参数的内容为空
binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(sdf, true));
}
}