upload file springboot Required request part 'file' is not present

前端 未结 4 532
感情败类
感情败类 2020-12-14 16:09

I want to add an upload function to my spring boot application; this is my upload Rest Controller

package org.sid.web;

import java.io.BufferedOutputStream         


        
4条回答
  •  失恋的感觉
    2020-12-14 16:26

    I also had similar issue and was getting the error request part file not present. But I later realized that I have this code in my application which was causing problem:

    @Bean(name = "multipartResolver")
        public CommonsMultipartResolver multipartResolver() {
            CommonsMultipartResolver multipartResolver = new 
            CommonsMultipartResolver();
            multipartResolver.setMaxUploadSize(1000000000);
            return multipartResolver;
          }
    

    I removed this and it started working for both RequestPart and RequestParam. See the related issue below:

    https://forum.predix.io/questions/22163/multipartfile-parameter-is-not-present-error.html

提交回复
热议问题