后台:
@RequestMapping
public void addEpibolyPool(@RequestParam("fileName") CommonsMultipartFile file,TEpibolyPool epibolyPool,HttpServletResponse response) {
logger.debug("EpibolyController add start...........");
System.out.println("开始上传文件啦。。。。。。。");
//上传文件
String fileName = null;
try {
InputStream in = file.getInputStream();
String uploadDir = "E:/";
File dirPath = new File(uploadDir);
if (!dirPath.exists()) {
dirPath.mkdirs();
}
fileName = uploadDir+file.getOriginalFilename();
File uploadedFile = new File(fileName);
byte[] bytes = file.getBytes();
FileCopyUtils.copy(bytes, uploadedFile);
System.out.println("********************************上传成功");
} catch (IOException e) {
e.printStackTrace();
}
epibolyPool.setPersonnelStatus("16");//初始状态
epibolyPool.setResideProvider(providerId);
epibolyPool.setCreateTime(new Date());
epibolyPool.setResumeLink(fileName);
String pk = epibolyService.save(epibolyPool);
logger.debug("EpibolyController add end........");
}
前台jsp:
<form action="../rest/epiboly/add" id="form1" method="post" enctype="multipart/form-data">
<input type="file" value="" class="text" name="fileName" style="width:120px"/>
</form>