Springboot通过前端发起请求,上传excel文件解析数据 postman进行操作

springboot版本3.2.0,数据库版本8

mybatisplus版本3.5.4.1

controller层
java 复制代码
    @PostMapping("/import")
    @ResponseBody
    public List<User> excelUpload( MultipartFile file) throws IOException{
        if (file==null){
            System.out.println("文件为空");
        }
      List<User> userList= EasyExcel.read(file.getInputStream(), User.class,new UserUploadListener(userService))
              .head(User.class)
               .sheet()
               .doReadSync();
        System.out.println(userList);
       return userList;
    }
测试结果
后端返回数据

Postman返回数据
注意

使用postman进行测试时,需要把key传进去,不然会报空文件异常,

相关推荐
2501_944424124 分钟前
Flutter for OpenHarmony游戏集合App实战之连连看路径连线
android·开发语言·前端·javascript·flutter·游戏·php
search77 小时前
前端设计:CRG 3--CDC error
前端
治金的blog7 小时前
vben-admin和vite,ant-design-vue的结合的联系
前端·vscode
利刃大大8 小时前
【Vue】Vue2 和 Vue3 的区别
前端·javascript·vue.js
荔枝一杯酸牛奶10 小时前
HTML 表单与表格布局实战:两个经典作业案例详解
前端·html
Charlie_lll10 小时前
学习Three.js–纹理贴图(Texture)
前端·three.js
yuguo.im10 小时前
我开源了一个 GrapesJS 插件
前端·javascript·开源·grapesjs
安且惜10 小时前
带弹窗的页面--以表格形式展示
前端·javascript·vue.js
GISer_Jing11 小时前
AI驱动营销:业务技术栈实战(From AIGC,待总结)
前端·人工智能·aigc·reactjs
小马爱打代码12 小时前
SpringBoot:封装 starter
java·spring boot·后端