【BUG】MultipartFile File has already been moved解决方案

场景:

      在springMVC框架中,针对文件上传来说multipartFile.transferTo方法的效率是较高的。但是在使用中往往会遇到MultipartFile File has already been moved这个问题,这是由于maxInMemorySize参数默认是10K,大于这个大小的文件会放到临时目录 当你读取的时候 判断的avaliable参数是false  因为已经不在内存里了 所以会报异常 所以一般你超过10K就挂了。

解决方案:

       修改maxInMemorySize参数。

<!-- 文件上传相关 -->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!--one of the properties available;the maximum upload size in bytes 100M-->
        <property name="maxUploadSize" value="104857600"/>
        <property name="maxInMemorySize" value="10240000" />  
    </bean>

猜你喜欢

转载自blog.csdn.net/IT_lyd/article/details/80180730