一、问题描述
Resolving exception from handler [public java.lang.String com.online.education.opt.controller.CourseSectionController.doImport(java.lang.Long,org.springframework.web.multipart.MultipartFile)]: org.springframework.web.bind.MissingServletRequestParameterException: Required MultipartFile parameter 'courseSectionExcel' is not present
[04/12 17:53] Resolving exception from handler [public java.lang.String com.online.education.opt.controller.CourseSectionController.doImport(java.lang.Long,org.springframework.web.multipart.MultipartFile)]: org.springframework.web.bind.MissingServletRequestParameterException: Required MultipartFile parameter 'courseSectionExcel' is not present
[04/12 17:53] Resolving exception from handler [public java.lang.String com.online.education.opt.controller.CourseSectionController.doImport(java.lang.Long,org.springframework.web.multipart.MultipartFile)]: org.springframework.web.bind.MissingServletRequestParameterException: Required MultipartFile parameter 'courseSectionExcel' is not present
[04/12 17:53] Null ModelAndView returned to DispatcherServlet with name 'app-servlet': assuming HandlerAdapter completed request handling
[04/12 17:53] Cleaning up multipart file [file] with original filename [导入课程章节模板.xlsx], stored in memory
[04/12 17:53]
二、问题解决
1、
有的说 true改成false,但这是掩耳盗铃
public String doImport(Long courseId,
@RequestParam(value = "courseSectionExcel", required = true) MultipartFile excelFile) {
}
2、name值与value值不同
<div class="layui-input-block">
<input type="file" name="file" id="courseSectionExcel" name="courseSectionExcel" "fileChange();">
</div>
两个name去掉前面那个。