# springboot-ajax-exportfile **Repository Path**: qianlingooo/springboot-ajax-exportfile ## Basic Information - **Project Name**: springboot-ajax-exportfile - **Description**: 此项目的demo实现的效果为,前端以ajax的形式提交请求,Spring Boot为框架的系统返回文件base64类型数据到前端使用blob技术下载文件。 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2020-06-18 - **Last Updated**: 2021-11-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # springboot-ajax-exportfile ### 介绍 此项目的demo实现的效果为,前端以ajax的形式提交请求,Spring Boot为框架的系统返回文件base64类型数据到前端使用blob技术下载文件。 ### 开发背景及步骤描述 在现在作者使用的原有技术框架中,导出文件一般是使用form表单提交的方式,但在后台捕捉到异常时,返回至前台是SpringBoot容器提供的页面, 无论是在阅读性还是美观方面都比较欠妥。 所以在查阅了资料后,决定使用Ajax进行请求,后台通过将**流的字节byte数组**转换为**base64类型的字符串数据**之后,传输至前台通过Blob的技术进行下载。 这种方式可在提交下载操作的时候进行日志自己录,也可在出现异常时使用layui等框架进行提示,而不是像原先在出现错误时,仅仅是通知用户连接超时 或异常。 并且直接将try-catch捕捉到的异常信息展示在前台,也会让客户觉得,emm...不够专业?:) ### 软件架构 #### 前端 1. layer-ui [https://layer.layui.com/](https://layer.layui.com/) 2. jquery [https://jquery.com/](https://jquery.com/) #### 后端 1. Spring Boot [https://spring.io/projects/spring-boot](https://spring.io/projects/spring-boot) 2. EasyExcel [https://github.com/alibaba/easyexcel](https://github.com/alibaba/easyexcel) 3. Apache Commons Lang [https://mvnrepository.com/artifact/org.apache.commons/commons-lang3](https://mvnrepository.com/artifact/org.apache.commons/commons-lang3) 4. Lombok [https://projectlombok.org/](https://projectlombok.org/)