(转)SpringBoot实现MultipartFile文件上传

转:SpringBoot实现MultipartFile文件上传 - 云+社区 - 腾讯云 (tencent.com)

1、SpringBoot采用FileUpload组件实现上传处理,在控制器中可以使用MultipartFile类进行接收。

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <project xmlns="http://maven.apache.org/POM/4.0.0"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
 5     https://maven.apache.org/xsd/maven-4.0.0.xsd">
 6     <modelVersion>4.0.0</modelVersion>
 7     <parent>
 8         <groupId>org.springframework.boot</groupId>
 9         <artifactId>spring-boot-starter-parent</artifactId>
10         <version>2.3.5.RELEASE</version>
11         <relativePath /> <!-- lookup parent from repository -->
12     </parent>
13     <groupId>com.example</groupId>
14     <artifactId>demo</artifactId>
15     <version>0.0.1-SNAPSHOT</version>
16     <name>demo</name>
17     <description>Demo project for Spring Boot</description>
18 
19     <properties>
20         <java.version>1.8</java.version>
21         <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
22     </properties>
23 
24     <dependencies>
25         <dependency>
26             <groupId>org.springframework.boot</groupId>
27             <artifactId>spring-boot-starter-web</artifactId>
28         </dependency>
29 
30         <dependency>
31             <groupId>org.springframework.boot</groupId>
32             <artifactId>spring-boot-starter-test</artifactId>
33             <scope>test</scope>
34             <exclusions>
35                 <exclusion>
36                     <groupId>org.junit.vintage</groupId>
37                     <artifactId>junit-vintage-engine</artifactId>
38                 </exclusion>
39             <
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章