Spring会将内容保存在内存中还是存储在磁盘中?

nov*_*ice 11 java spring-mvc apache-commons-fileupload

当一个文件说从浏览器上传100 MB大小时,Spring将整个数据保存在内存中或临时存储在磁盘中.在通过Spring doc之后,我知道如何设置临时目录,但我想知道如果我不提及会发生什么.

我有以下声明:

<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
Run Code Online (Sandbox Code Playgroud)

豆 :

public class FileHolder {

    private MultipartFile file;

    public void setFile(MultipartFile file) {
        this.file = file;
    }

    public MultipartFile getFile() {
        return file;
    }
}
Run Code Online (Sandbox Code Playgroud)

上面的bean中的"file"对象是否会保存100 MB的数据?

ska*_*man 12

javadoc中的更多内容显示默认的最大内存大小为10240字节.由此我假设任何小于10kB的上传都保存在内存中,任何更大的内容都将存储在磁盘上.如果你没有指定磁盘位置,它可能会使用默认值(我猜它会使用系统默认的tmp目录).