spring MVC报错 Expected MultipartHttpServletRequest: is a MultipartResolver configured?

在使用Spring MVC进行图片上传的时候,报错

严重: Servlet.service() for servlet [taotao-manager] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Expected MultipartHttpServletRequest: is a MultipartResolver configured?] with root cause
java.lang.IllegalArgumentException: Expected MultipartHttpServletRequest: is a MultipartResolver configured?
at org.springframework.util.Assert.notNull(Assert.java:112)
.......


这是由于在spring MVC进行文件上传的时候,需要在springmvc.xml文件中配置多部件解析器。注:需要引入文件上传的jar包,file-upload和common-io


配置如下:


class="org.springframework.web.multipart.commons.CommonsMultipartResolver">





重启tomcat,问题解决。

你可能感兴趣的:(错误调试)