MultipartRequest获取参数

@RequestMapping(value = "/importChapter",method = RequestMethod.POST)
    @ResponseBody
    public Result importChapter(MultipartRequest request){
        //获得工作簿
        ExcelReaderBuilder read = null;
        try {

            String coursesId = ((StandardMultipartHttpServletRequest) request).getParameterMap().get("coursesId")[0];
            InputStream inputStream = request.getFile("file").getInputStream();
            //实例化实现了AnalysisEventListener接口的类
            ChapterExcelListener listener = new ChapterExcelListener();
            listener.setCourseService(service);
            listener.setCoursesId(coursesId);
            //获得工作簿
            read = EasyExcel.read(inputStream, Chapter.class, listener);
            //获得工作表  又两种形形式可以通过下标也可以通过名字2003Excel不支持名字
            ExcelReaderSheetBuilder sheet = read.sheet();
            //进行读操作
            sheet.doRead();

        } catch (IOException e) {
            e.printStackTrace();
        }


        return ResultUtil.success();
    }

你可能感兴趣的:(springboot,Multipart)