org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.jboss.resteasy.plug


之前做的項目是resteasy的上傳,代碼沒有問題,斷點都不進來呢。

我以為可以直接移植到SpringMVC,但是SpringMVC不支持MultipartFormDataInput

用MultipartFile就可以了。老的無法兼容新的。正確代碼如下

 
         
@RequestMapping(value = "/importExcelForEduQuestion",produces = "application/json; charset=utf-8")
@ResponseBody
//@RequiresPermissions("eduQuestionBank:importExcelForEduQuestion")
public Map<String,Object> importExcelForEduQuestion(HttpServletRequest request, @RequestParam("excelPath") MultipartFile file){
//如果文件不為空,寫入上傳路徑
if(!file.isEmpty()) {
//上傳文件路徑
//上傳文件名
String filename = file.getOriginalFilename();
File filepath = new File(UPLOADED_FILE_PATH,filename);
//判斷路徑是否存在,如果不存在就創建一個
if (!filepath.getParentFile().exists()) {
filepath.getParentFile().mkdirs();
}
//將上傳文件保存到一個目標文件當中
try {
file.transferTo(new File(UPLOADED_FILE_PATH + File.separator + filename));
} catch (IOException e) {
e.printStackTrace();
}
return ResultUtil.createSuccessResult();
} else {
return ResultUtil.createFailResult("上傳失敗");
}
}
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM