1、controller:
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public void importExcel(@RequestParam(value = "file", required = true) MultipartFile file) {
baseService.importExcel(file);
}
2、service(UploadUtil和ExcelUtil工具类查看本人另外博客):
@Value("${spring.application.name}")
private String applicationName;
public String importExcel(MultipartFile file){
Map map = UploadUtil.upload("/" + applicationName, file);
String localFilePath = map.get("localFilePath").toString();
List<VoExcel> VoList = ExcelUtil.importExcel(localFilePath, 0, 1, VoExcel.class);
for (VoExcel vo: VoList) {
}
return "";
}