Open oolongsawel opened 2 years ago
에러로그
2022-09-25 22:55:29.185 WARN 7624 --- [nio-8080-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved
[org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult:
2 errors<EOL>Field error in object 'ordersForm' on field 'orderDate': rejected value [2022-09-26]; codes
[typeMismatch.ordersForm.orderDate,typeMismatch.orderDate,typeMismatch.java.util.Date,typeMismatch]; arguments
[org.springframework.context.support.DefaultMessageSourceResolvable: codes [ordersForm.orderDate,orderDate]; arguments
[]; default message [orderDate]]; default message [Failed to convert property value of type 'java.lang.String' to required type
'java.util.Date' for property 'orderDate'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed
to convert from type [java.lang.String] to type [java.util.Date] for value '2022-09-26'; nested exception is
java.lang.IllegalArgumentException]<EOL>Field error in object 'ordersForm' on field 'pickUpDate': rejected value [2022-09-25];
codes [typeMismatch.ordersForm.pickUpDate,typeMismatch.pickUpDate,typeMismatch.java.util.Date,typeMismatch]; arguments
[org.springframework.context.support.DefaultMessageSourceResolvable: codes [ordersForm.pickUpDate,pickUpDate];
arguments []; default message [pickUpDate]]; default message [Failed to convert property value of type 'java.lang.String' to
required type 'java.util.Date' for property 'pickUpDate'; nested exception is
org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type
[java.util.Date] for value '2022-09-25'; nested exception is java.lang.IllegalArgumentException]]
참고 : Spring MVC 에서 Date 타입의 파라미터 처리 https://www.hungrydiver.co.kr/bbs/detail/develop?id=73
AS-IS
@Getter
@Setter
@ToString
public class OrdersForm {
private Date orderDate; //주문날짜
private Date pickUpDate; //찾은날짜
}
TO-BE
@Getter
@Setter
@ToString
public class OrdersForm {
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date orderDate; //주문날짜
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date pickUpDate; //찾은날짜
}
주문정보 데이터가 들어가는 테이블 생성