一、Html上传文件表单
</!DOCTYPE html>
<html>
<head>
<title>test upload</title>
</head>
<body>
<h1>hello</h1>
<form action="http://localhost:8080/test/upload" method="post" enctype="multipart/form-data">
<input type="file" name="file"/>
<input type="submit" value="Submit" />
</form>
</body>
</html>
二、后台代码
@PostMapping( value = "upload")
@ResponseBody
public String upload(@RequestParam("file") MultipartFile multipartFile) throws IOException {
String originName = multipartFile.getOriginalFilename();
multipartFile.transferTo(new File(originName));
return "ok";
}