방법 1 (옛날 방법)
Controller
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd");
binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(df,false));
}
@Data
public class TodoDTO {
private String title;
private Date dueDate;
}
@GetMapping("/ex03")
public String ex03(TodoDTO todo) {
log.info("todo: " + todo);
}
방법 2 (최근 방법 Spring 에서 지원)
@Data
public class TodoDTO {
private String title;
@DateTimeFormat(pattern="yyy/MM/dd")
private Date dueDate;
}
'Spring' 카테고리의 다른 글
VS CODE (비쥬얼 스튜디오 코드에서) Spring boot 실행 (RUN) (0) | 2020.04.03 |
---|---|
마이크로서비스에서 DDD 사용하기 (0) | 2020.03.05 |
Spring 동작원리 (0) | 2019.02.27 |
HTTP Status 404 - /WEB-INF 에러 (0) | 2019.02.25 |
Spring MVC 구성 요소 (0) | 2019.02.23 |