在使用springMvc做文件上传的时候出现
HTTP Status 500 - Failed to convert value of type [java.lang.String] to required type [org.springframework.web.multipart.commons.CommonsMultipartFile]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.commons.CommonsMultipartFile]: no matching editors or conversion strategy found
不知觉中的原因:
这里没有写method方法,
并且后台是用CommonsMultipartFile接受的。
这里要写清楚文件上传的形式。如果用get请求,数据是直接接在url后面,但是我们知道url里面是放不了多少数据的,
所以只有用post请求,将数据放置在消息体里。