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

相关推荐
zhangxingchao1 小时前
Kotlin常用的Flow 操作符整理
前端
IT_陈寒2 小时前
React的useState居然还有这种坑?我差点删库跑路
前端·人工智能·后端
Pedantic3 小时前
SwiftUI 手势笔记
前端·后端
橙子家4 小时前
浏览器缓存之【结构化数据库与缓存】: IndexedDB、Cache storage 和 Storage buckets
前端
user20585561518134 小时前
X6 中边悬浮置顶,规避 `mouseleave` 事件丢失问题
前端
李明卫杭州4 小时前
CSS aspect-ratio 属性完全指南
前端
Pedantic6 小时前
SwiftUI 手势层级(Gesture Hierarchy)详解
前端
飘尘6 小时前
前端转型全栈(Java后端)的快速上手指引
前端·后端·全栈
一颗烂土豆6 小时前
Meshopt 压缩深度解析,为什么它比 Draco 更快
前端·javascript·webgl