springboot文件上传 MultipartFile file,源自SpringMVC
1.1)静态页面直接访问:localhost:8080/index.html
注意点: 如果想要直接访问html页面,则需要把html放在springboot默认加载的文件夹下面,如public等; 同时把pom.xml文件的thymeleaf依赖注释掉。
HTML代码:
<!DOCTYPE html>
<html>
<head>
<title>uploadimg.html</title>
<meta name="keywords" content="keyword1,keyword2,keyword3"></meta>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="/js/test.js" type="text/javascript"></script>
</head>
<body>
<form enctype="multipart/form-data" method="post" action="/upload">
文件:<input type="file" name="head_img"/>
姓名:<input type="text" name="name"/>
<input type="submit" value="上传"/