• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

강사님 현재 등록하는 부분에서 오류가 나는데 이유를 모르겠습니다.

21.07.07 15:09 작성 조회수 979

0

화면에서 아이템을 등록하려고 합니다. 

배송방식을 추가하고나서부터 상품 등록 버튼을 누르는 순간400에러가 떨어지는데요ㅠㅠ

20분을 헤멧는데도 이유를 알 수 없어서 질문드립니다.

[컨트롤러]

[DeliveryCode]

[addForm.html]

오류 메시지를 간략하게 적어보면 아래와 같습니다.

2021-07-07 15:10:15.833  WARN 20644 --- [nio-8080-exec-9] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors

Field error in object 'item' on field 'deliveryCode': rejected value [FAST]; codes [typeMismatch.item.deliveryCode,typeMismatch.deliveryCode,typeMismatch.hello.itemservice.domain.item.DeliveryCode,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [item.deliveryCode,deliveryCode]; arguments []; default message [deliveryCode]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'hello.itemservice.domain.item.DeliveryCode' for property 'deliveryCode'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'hello.itemservice.domain.item.DeliveryCode' for property 'deliveryCode': no matching editors or conversion strategy found]]

답변 2

·

답변을 작성해보세요.

1

hanul_kr님의 프로필

hanul_kr

2021.07.07

혹시 hello.itemservice.domain.item.Item
Item의 필드 중에 deliveryCode를 String 타입이 아닌 다른 타입으로 정의해둔 것이 아닐까 싶습니다.

private ItemType itemType;  // 상품 종류
private DeliveryCode deliveryCode; // 배송방식

이렇게 작성해두셨나요..>?

그렇다면 아래처럼 바꿔주시면 될 것 같습니다.

private ItemType itemType;  // 상품 종류
private String deliveryCode; // 배송방식

hanul_kr님 답변 감사합니다^^

김은재님의 프로필

김은재

질문자

2021.07.08

와우 해결되었네요

언제 String으로바꾸셨나요 강사님 ㅋㅋㅋ

0

필로님의 프로필

필로

2021.09.04

오 ㅎㅎ 감사합니다 저도 같은 부분에서 막히고 있었습니다 ㅎ