当前位置:网站首页>7.3.2 File Download & big file download

7.3.2 File Download & big file download

2020-11-06 01:14:00 Memory

All the source code in the project can be found in the linked repository :https://github.com/chenhaoxiang/uifuture-ssm

7.3.2 adopt ResponseEntity Download the file

7.3.1 Section shows the transfer of files and objects , Now let's show you Spring MVC File download in .

The file download is relatively simple , You can also download files directly from the page by accessing the hyperlink to the file . But if the file name is Chinese name , It's possible that in some early browsers, it could lead to garbled code , So the download failed .

Spring MVC Provides ResponseEntity type , It is very convenient to define return header, return file name and status code .

stay FileController Add download method in . Take a look at Controller Class provides the download file method , Such as code list 7-27 Shown .

Controller Download method of layer

Code list 7-27:Controller Download method of layer

/**
 *  If there's a big file , Meeting OOM.
 *  There will be java.lang.OutOfMemor

版权声明
本文为[Memory]所创,转载请带上原文链接,感谢