文件上传 ,java.lang.IllegalStateException: File has been moved - cannot be read again org.springframewor

原创 2016年08月31日 17:10:04

启动新线程进行文件上传 报:,java.lang.IllegalStateException: File has been moved - cannot be read again org.springframewor错误

查看多媒体文件上传处理类支持的上传大小设置合理

<!-- 上传文件拦截,设置最大上传文件大小 10M=10*1024*1024(B)=10485760 bytes -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="${web.maxUploadSize}" />
</bean>

查看源码:

@Override

public void transferTo(File dest) throws IOException, IllegalStateException {
if (!isAvailable()) {
throw new IllegalStateException("File has already been moved - cannot be transferred again");
}

....
}

文件是否合法,

protected boolean isAvailable() {
// If in memory, it's available.
if (this.fileItem.isInMemory()) {
return true;
}
// Check actual existence of temporary file.
if (this.fileItem instanceof DiskFileItem) {
return ((DiskFileItem) this.fileItem).getStoreLocation().exists(); 在此返回false
}
// Check whether current file size is different than original one.
return (this.fileItem.getSize() == this.size);
}

这是说明该文件不存在,为什么会出现不存在呢?

如果我不用新的线程上传文件,则不会出现该问题.

为什么在新的线程中上传文件出现该问题?



相关文章推荐

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

在用jqueryfileupload上传文件时报如下错误: java.lang.IllegalStateException: File has been moved - cannot be read...

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

在用jqueryfileupload上传文件时报如下错误: java.lang.IllegalStateException: File has been moved - cannot be read...

java.lang.IllegalStateException异常产生的原因及解决办法

问题描述: 错误类型大致为以下几种: java.lang.IllegalStateException:Cannot   forward   a   response   that   is...

文件上传获取属性时:File has been moved - cannot be read again

http://blog.csdn.net/sidongxue2/article/details/45366471

图片上传IllegalStateException File has been moved - cannot be read again解决

功能描述:1,上传图片保存至数据库                2,将该图片按scale=125/width > 125/height ? 125/height : 125/width的比例缩小,...
  • yqj1988
  • yqj1988
  • 2011年04月29日 11:48
  • 3843

偶尔发生File has been moved - cannot be read again,其实是个误解

java

java.lang.IllegalStateException: Cannot create a session after the response has been committed

2012-2-21 16:10:11 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for s...
  • c5153000
  • c5153000
  • 2012年02月21日 16:26
  • 25629

Cannot forward after response has been committed问题解决及分析

通过TOMCAT把系统启动,可以正常登陆门户,登陆进去选择子系统的时候点击登陆的时候,可是去又回到了登陆界面,如此反复就是不能够进入子系统,查看后台报的错误: Cannot forward afte...

java.lang.IllegalStateException: Cannot forward after response has been committed几个解决方法

在一个项目中jsp页面出现这个问题。011-5-30 16:03:22 org.apache.catalina.core.ApplicationDispatcher invoke 严重: Servl...

java.lang.IllegalStateException:Cannot add header view to list==setAdapter has already been called.

java.lang.IllegalStateException:Cannot add header view to list==setAdapter has already been called.
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:文件上传 ,java.lang.IllegalStateException: File has been moved - cannot be read again org.springframewor
举报原因:
原因补充:

(最多只允许输入30个字)