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传进去,不然会报空文件异常,

相关推荐
dsyyyyy110112 分钟前
HTML总结
前端·html
前端那点事44 分钟前
深度解析:Vue中computed的实现原理(易懂不晦涩)
前端·vue.js
Mike_jia1 小时前
PortNote:可视化端口管理工具,让端口冲突成为历史
前端
前端那点事1 小时前
Vue中深克隆的3种实现方案(附详细注释+测试)
前端·vue.js
存在X1 小时前
claude code自定义模型
前端·claude
Highcharts.js1 小时前
赋能金融 SaaS|如何利用 Highcharts 与 Morningstar 数据构建顶级分析仪表盘
前端·金融·echarts·saas·bi·highcharts
啷咯哩咯啷1 小时前
纯本地运行的私人文档知识库
前端·人工智能·后端
❆VE❆1 小时前
基于 contenteditable 实现变量插入富文本编辑器
前端·javascript·vue.js
Aliex_git1 小时前
Nuxt 学习笔记(一)
前端·笔记·学习
烤麻辣烫1 小时前
json与fastjson
前端·javascript·学习·json