java.lang.IllegalStateException: File has been moved - cannot be read again

在用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>  


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值