spring mvc MultipartFile 上传文件错误解决

时间:2022-10-17 18:57:37

Field error in object 'xxxx' on field 'xxxx': rejected value [20129259128131.jpg]; codes [typeMismatch.xxxx.xxxx,typeMismatch.xxxx,typeMismatch.org.springframework.web.multipart.MultipartFile,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [xxxx.xxxx,xxxx]; arguments []; default message [shoplogo_]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile' for property 'shoplogo_'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.MultipartFile] for property 'shoplogo_': no matching editors or conversion strategy found]

出现类似错误,检查form表单属性是否写上enctype="multipart/form-data"。