在ssm项目中,前端使用element组件,版本为1.6.2.axios完成文件上传,此时文件可正常完成上传。
在springboot项目中,使用相同版本的axios,后端参接收时会报空指针异常,需降低axios版本。
1.空指针:
删除axios:
npm uninstall axios
安装低版本:
npm i axios@1.4.0
2.java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
Failed to parse multipart servlet request; nested exception is java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
解决办法:
第一步:拉取依赖
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
第二步:在启动类中添加如下代码
@Bean(name="multipartResolver")
public MultipartResolver multipartResolver(){
return new CommonsMultipartResolver();
}