Spring mvc 图片上传,public void savePhoto(InputStream inputStream) throws Exception 里面怎么写
@RequestMapping("saveAdvertFile.action")
public ModelAndView saveAdvertFile(@RequestParam MultipartFile loadPicPath, HttpServletRequest request)
{
if (loadPicPath != null)
{
log.info("file name=" + loadPicPath.getOriginalFilename());
//保存图片路径
String realPath = CConstants.ADV_ROOT_PATH
+ System.currentTimeMillis() + loadPicPath.getOriginalFilename();
try
{File newFile = new File(realPath);
loadPicPath.transferTo(newFile);
status.setFilePath(realPath);
status.setLoadSuccess(true);
}
catch (Exception e)
{
log.error("error file load:" + e);
status.setFilePath("");
status.setLoadSuccess(false);
}
}
else
{
log.info("file name=null.");
}
return forward("/view/schedule/advert-notify", null);
}