1、html页
<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8 ">
<title>图片上传</title>
</head>
<body>
<form enctype="multipart/form-data" method="post" action="/back/uploadImg">
选择文件:<input type="file" name="imgUpload">
<input type="submit" value="上传">
</form>
<img th:src="${filename}">
<input type="hidden" name="filePath" th:value="${filePath}">
</body>
</html>
2、uploadUtil:上传
public static void uploadImg(MultipartFile file, String filePath){