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

启动新线程进行文件上传 报:,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类 文件上传
上一篇maven 工程 update project 报空指针
下一篇maven 依赖 war包问题
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭