form-data 类型即常用的表单提交
两种处理参数的方式
@RequestPart 作用类似 @RequestParam

直接上代码
@RestController
public class TestFile {
private BufferedOutputStream bufferedOutputStream = null;
@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ResponseBody
public String readFile(HttpServletRequest request, @RequestParam("name") String name, @RequestPart("file1") MultipartFile file3,@RequestPart("photo") MultipartFile photo) throws IOException, ServletException {
String path= "I:\spring\spring-mybatis-plus\src\main\resources\public\static\";
System.out.println(name);
/*
第一种 : 使用 MultipartFile 封装好的 transferTo() 方法保存文件
photo.transferTo(new File(path+photo.getOriginalFilename()));
第二种 : 使用 MultipartFile 字节流保存文件
fileUtil(file3, String.valueOf(path));
第三种 : 使用 Part 接收文件字节流
Part file2 = request.getPart("file2");
file2.write(path + file2.getSubmittedFileName());
*/
// request.getParts() 获取的是全部参数(name,age,file1,file2),包括文件参数和非文件参数
for (Part part : request.getParts()) {
// 获取文件类型
part.getContentType();
// 获取文件大小
part.getSize();
// 获取文件名
part.getSubmittedFileName();
// 获取参数名 (name,age,file1,file2)