Spring
[Spring] @ModelAttribute 사용시 Date 날짜형 처리
yjseo
2016. 2. 2. 13:15
@ModelAttribute를 사용해 파라미터값들을 받을때 Date형의 input값이 비어있으면 오류가 발생한다.
컨트롤러 클래스 상단에 다음과 같이 소스를 넣어주어 해결한다.
@InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); }