Upload and download of spring implementation files

Source: Internet
Author: User

Background: What has been done before is the database of additions and deletions to work, for file upload download is more exclusive, today study the next specific implementation, found in fact is very simple. Here not only to achieve a single file upload, but also to achieve a multi-file upload.

Single File download, you know, a lot of files download it??

I use the spring boot here to quickly build the Spring MVC framework, thieves convenient, not all can not afford to themselves.

This blog will explain the Springmvc file upload and download features. For the upload function, we are often used in the project, such as user registration, upload the user's avatar, this time will be used to upload the function. For the download, the use of the scene is also very common, such as our project has a description of the use is a PDF version, will provide users with the ability to download. These two functions are common in comparison to each other.

A: Build SPRINGMVC development environment

Use spring boot to build the MVC framework.

File directory:

Pom.xml file dependencies:

<?XML version= "1.0" encoding= "UTF-8"?><Projectxmlns= "http://maven.apache.org/POM/4.0.0"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelversion>4.0.0</modelversion>    <groupId>Spring.boot</groupId>    <Artifactid>UploadFile</Artifactid>    <version>0.0.1-snapshot</version>    <Packaging>Jar</Packaging>    <name>UploadFile</name>    <Description>Demo Project for Spring Boot</Description>    <Parent>        <groupId>Org.springframework.boot</groupId>        <Artifactid>Spring-boot-starter-parent</Artifactid>        <version>2.0.0.RELEASE</version>        <RelativePath/> <!--Lookup parent from repository -    </Parent>    <Properties>        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>        <java.version>1.8</java.version>    </Properties>    <Dependencies>        <Dependency>            <groupId>Org.springframework.boot</groupId>            <Artifactid>Spring-boot-starter-web</Artifactid>        </Dependency>        <Dependency>            <groupId>Org.springframework.boot</groupId>            <Artifactid>Spring-boot-starter-test</Artifactid>            <Scope>Test</Scope>        </Dependency>        <!--JSP pages use JSTL tags -        <Dependency>            <groupId>Javax.servlet</groupId>            <Artifactid>Jstl</Artifactid>        </Dependency>        <!--for compiling JSPs -        <Dependency>            <groupId>Org.apache.tomcat.embed</groupId>            <Artifactid>Tomcat-embed-jasper</Artifactid>            <Scope>Provided</Scope>        </Dependency>        <!--Https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -        <!--configuration file Upload Bean control file large size, encoding, etc. -        <Dependency>            <groupId>Commons-fileupload</groupId>            <Artifactid>Commons-fileupload</Artifactid>            <version>1.3</version>        </Dependency>        <!--Https://mvnrepository.com/artifact/org.apache.commons/commons-io -        <!--the Fileutil tool class to which it is used -        <Dependency>            <groupId>Org.apache.commons</groupId>            <Artifactid>Commons-io</Artifactid>            <version>1.3.2</version>        </Dependency>    </Dependencies>    <Build>        <Plugins>            <plugin>                <groupId>Org.springframework.boot</groupId>                <Artifactid>Spring-boot-maven-plugin</Artifactid>            </plugin>        </Plugins>    </Build></Project>

Upload and download of spring implementation files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.