加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

java.lang.IllegalStateException: File has been moved - canno

发布时间:2020-12-13 20:42:47 所属栏目:PHP教程 来源:网络整理
导读:在用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.

在用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参数,还有1个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⑷.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context⑷.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>


(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读