spring mvc上传图片容器版本问题tomcat jetty 1C

出现的了一个头疼的问题,同样的代码用spring mvc提供的上传图片,在tomcat 6 和7下运行出现参数不能绑定,而在jetty8和9.1运行正常(jetty9.2也报跟tomcat同样的错误)我估计是java-servlet-api的版本问题。有哪位小伙伴出现过类似的问题怎么解决的?谢谢

spring mvc配置

 <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="104857600" />
         <property name="defaultEncoding" value="utf-8"/> 
        <property name="maxInMemorySize" value="4096" />
    </bean>  

错误:

HTTP Status 500 - Required MultipartFile[] parameter 'sportPhoto' is not present

type Exception report

message Required MultipartFile[] parameter 'sportPhoto' is not present

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.springframework.web.bind.MissingServletRequestParameterException: Required MultipartFile[] parameter 'sportPhoto' is not present
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.raiseMissingParameterException(AnnotationMethodHandlerAdapter.java:786)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestParam(HandlerMethodInvoker.java:508)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:347)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:170)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
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:107)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.64 logs.

图片说明

图片说明

2个回答

sportPhoto 参数?

通常是使用springmvc文件上传,报该错,有可能表单参数和control里方法参数不一致,检查下你的Action代码中的参数名称和页面文件表单的名称是否一致呢?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问