标签:file has been moved maxinmemorysize maxuploadsize spring commonsmultipartreso
在用jqueryfileupload上传文件时报如下错误:
java.lang.IllegalStateException: File has been moved - cannot be read again
后台接口是spring mvc, 检查sprnig mvc配置文件:
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize"> <value>102400000</value> </property> </bean>配置了允许上传文件的最大size, 而自己上传的文件大小远远小于这个,什么情况呢?
经过网上搜索资料,发现spring mvc除了maxUploadSize参数,还有一个maxInMemorySize参数,指定允许文件被写入内存的最大szie,则默认为1024字节,即1MB,如果试上传大于1024个字节的文件,你需要增加maxInMemorySize价。
如下:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!-- 添加拦截器 --> <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="interceptors"> <bean class="com.message.web.interceptor.SessionInterceptor" /> </property> </bean> <!-- 配置controller扫描 --> <context:component-scan base-package="com.message.web.controller" /> <!-- 配置springmvc视图解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass"> <value>org.springframework.web.servlet.view.JstlView</value> </property> <property name="prefix"> <value>/message/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> <!-- 设置上传文件的最大尺寸为100MB --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize"> <value>102400000</value> </property> <property name="maxInMemorySize"> <value>10240000</value> </property> </bean> </beans>
java.lang.IllegalStateException: File has been moved - cannot be read again
标签:file has been moved maxinmemorysize maxuploadsize spring commonsmultipartreso
原文地址:http://blog.csdn.net/sidongxue2/article/details/45366471