<form method="post" action="/file" enctype="multipart/form-data">
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form method="post" action="/file" enctype="multipart/form-data">
<input type="file" name="file" id="file">
<input type="submit" value="submit">
</form>
</body>
</html>
public void file(@RequestParam("file") MultipartFile file) throws IOException
package com.example.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
@Controller
public class ControllerFile {
@ResponseBody
@RequestMapping("/file")
public void file(@RequestParam("file") MultipartFile file) throws IOException {
System.out.println(file.getOriginalFilename());
System.out.println(file.getName());
}
}