2020-05-31
最近有个需求是上传文件到服务器,使用到的框架是springboot,查询资料后记录如下。
1.添加基本依赖
这是第一步,但一般建立springboot项目的时候能够勾选该启动依赖。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2.前端form
这是我项目中提交文件的前端代码,这个就因人而异了。(使用的thymeleaf)
<div class="card">
<div class="card-header">
文件上传
</div>
<div class="card-body card-block">
<form th:action="'/upload?projectid='+${project.projectid}" method="po