java-SpringMVC 后台怎么获取前台jsp页面中file中的文件
2个回答
展开全部
//保存上传文件到服务器指定的目录和文件名
public void saveFileToServer(JspUpdatePageCommand commandbean, HttpServletRequest request) throws Exception {
logger.debug("保存文件到服务器指定的文件【" + this.getsServerTempFileName() + "】");
byte[] bytes = commandbean.getFile();
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("file");
File uploadedFile = new File(this.getsServerTempFileName());//this.getsServerTempFileName()服务器上文件名
FileCopyUtils.copy(bytes, uploadedFile);
this.setOriginalFilename(file.getOriginalFilename());
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询