SpringBoot 文件上传
SpringBoot 文件上传
1.编写 html 文件在 classpath 下的 static 中
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>文件上传</title>
</head>
<body>
<form action="fileUploadController" method="post"
enctype="multipart/form-data">
上传文件:<input type="file" name="filename"/> <br/>
<input type="submit"/>
</form>
</body>
</html>
2.编写处理文件上传的类和方法
/**
* SpringBoot 文件上传
*/
//这个类下的所有方法返回值自动做 json 格式的转换。类似@Controller + @ResponseBody
@RestController