zoukankan      html  css  js  c++  java
  • Spring MVC实现上传文件报错解决方案

    报错代码:

    org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.multipart.MultipartFile]: Specified class is an interface
        org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:101)
        org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveModelAttribute(HandlerMethodInvoker.java:762)
        org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:356)
        org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
        org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
        org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
        org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
        org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

    解决方案:在Controller的MultipartFile参数前面加上@RequestParam就解决了!

  • 相关阅读:
    实战parse_ini_file()及扩展函数解析ini文件完整版
    Android应用程序注冊广播接收器(registerReceiver)的过程分析
    LeetCode: Best Time to Buy and Sell Stock II [122]
    关于URL编码
    js进阶 14-1 jquery的ajax系列中的load方法的作用是什么
    js进阶 13 jquery动画函数有哪些
    js进阶 13-11/12 jquery如何实现折叠导航
    js进阶 13-9/10 jquery如何实现三级列表
    js进阶 13-8 jquery如何实现侧边栏
    js进阶 13-7 如何实现滑动面板效果
  • 原文地址:https://www.cnblogs.com/liuling/p/2014-3-5.html
Copyright © 2011-2022 走看看