SpringBoot上传文件异常-Required request part 'file' is not present

org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'file' is not present
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [13 skipped]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [1 skipped]
    at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55) [2 skipped]
    at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110) [3 skipped]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [44 skipped]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

异常原因

指定了上传文件的处理器

    @Bean
    public MultipartResolver multipartResolver() {
        return new CommonsMultipartResolver();
    }

解决办法

注释掉,不指定文件处理器

你可能感兴趣的:(SpringBoot上传文件异常-Required request part 'file' is not present)