01 | package sy.controller; |
02 |
03 | import java.text.SimpleDateFormat; |
04 | import java.util.Date; |
05 |
06 | import org.apache.log4j.Logger; |
07 | import org.springframework.stereotype.Controller; |
08 | import org.springframework.web.bind.ServletRequestDataBinder; |
09 | import org.springframework.web.bind.annotation.InitBinder; |
10 | import org.springframework.web.bind.annotation.RequestMapping; |
11 |
12 | import sy.util.CustomDateEditor; |
13 |
14 | /** |
15 | * |
16 | * 项目名称:sypro |
17 | * 类名称:BaseController |
18 | * 类描述: 基础控制器,其他控制器需extends此控制器获得initBinder自动转换的功能 |
19 | * 创建人:君无邪 |
20 | * 创建时间:2015年11月15日 下午4:58:21 |
21 | * 修改备注: https://www.java214.com |
22 | * @version 1.0 |
23 | * |
24 | */ |
25 | @Controller |
26 | @RequestMapping ( "/baseController" ) |
27 | public class BaseController { |
28 |
29 | private static final Logger logger = Logger.getLogger(BaseController. class ); |
30 |
31 | /** |
32 | * 将前台传递过来的日期格式的字符串,自动转化为Date类型 |
33 | * |
34 | * @param binder |
35 | * |
36 | */ |
37 | @InitBinder |
38 | public void initBinder(ServletRequestDataBinder binder) { |
39 | SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); |
40 | // dateFormat.setLenient(false); |
41 | binder.registerCustomEditor(Date. class , new CustomDateEditor(dateFormat, true )); |
42 | // binder.registerCustomEditor(String.class, new StringTrimmerEditor(false)); |
43 | } |
44 |
45 | } |


qiheideguang LV18
2024年12月4日
bluerstar LV1
2024年10月23日
zhengguangshun LV4
2024年8月25日
chn-lei LV2
2024年7月31日
gaowang LV1
2024年5月29日
poilkj1313 LV1
2024年5月10日
zpppppppppppppppppp
2024年4月20日
暂无贡献等级
1303891 LV1
2024年4月14日
123dwda
2024年3月17日
暂无贡献等级
aachl1 LV5
2024年1月16日