现有的做法是用MultipartFile类读取excel文件以后用transferTo()转存到硬盘上,请问能不能不用转存到硬盘直接用File类读取,试过将其强制转换成File类型结果报错。
目前做法的代码:
Controller层:@RestController
@RequestMapping("/excel")
public class ExcelFileController {
//注入excel服务
@Resource
private ExcelService excelService;
@RequestMapping(value = "/upload",method = RequestMethod.POST)
public String ExcelFileUpload(@RequestParam("file") MultipartFile file){
if(excelService.uploadExcelToSQL(file)){
return "true";
}else{
return "false";
}
}
}
Service层实现类:@Service
public class ExcelSerivceImpl implements ExcelService {
/**
* 将读取到的Excel文件存入数据库中接口实现
*/
@Override
public boolean u