brkuhgk / dosa-cloud

springboot example
0 stars 0 forks source link

Data Binding Missmatch Type error #1

Open brkuhgk opened 1 month ago

brkuhgk commented 1 month ago

After creating the Dosa, I submitted the form, but the error message MissMatch was shown.

Error:

There was an unexpected error (type=Bad Request, status=400). Validation failed for object='dosa'. Error count: 1

Resolved [org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public java.lang.String org.food.dosacloud.DesignDosaController.handlePostReqDosaForm(org.food.dosacloud.Dosa,org.food.dosacloud.DosaOrder): [Field error in object 'dosa' on field 'ingredients': rejected value [PD,KEGGPD,RSD]; codes [typeMismatch.dosa.ingredients,typeMismatch.ingredients,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [dosa.ingredients,ingredients]; arguments []; default message [ingredients]]; default message [Failed to convert property value of type 'java.lang.String[]' to required type 'java.util.List' for property 'ingredients'; Cannot convert value of type 'java.lang.String' to required type 'org.food.dosacloud.Ingredient' for property 'ingredients[0]': no matching editors or conversion strategy found]] ]

brkuhgk commented 1 month ago

Its Due to Miss Match of Dosa object and string text submitted by form. Dosa object contain a Ingrediant Object. Fix: by Spring Converter Interface.