问题1:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade
程序刚一运行访问就抛出了上面的类型转换异常信息,根据提示信息,找到了导致该异常的代码行:
MultipartHttpServletRequest multipartRequest=(MultipartHttpServletRequest)request;
MultipartFile file=multipartRequest.getFile("upload");
这个问题花费了我很多时间和精力,查找了很多相关资料之后,发现我的配置文件里少了对multipart解析器的配置:




添加上之后,运行,访问,上面的异常终于没有再出现,但是新的问题又来了

问题2:


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'multipartResolver' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
这次的问题很明确,缺少文件包,添加commons-fileupload-1.2.jar,问题解决,接着又出新问题

问题3:

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
添加commons-io-1.3.1,问题解决,
至此,整个程序终于可以完整的运行,正常上传

0 Comments:

Post a Comment



 
Copyright 2005-2007. Hello Wiki designed by Fen, Blogger Templates by Blogcrowds.