发布网友 发布时间:2022-04-23 04:04
共2个回答
热心网友 时间:2023-07-04 21:02
boolean isMultipart = ServletFileUpload.isMultipartContent(request);//判断是否是表单文件类型
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload sfu = new ServletFileUpload(factory);
List items = sfu.parseRequest(request);//从request得到所有上传域的列表
for(Iterator iter = items.iterator();iter.hasNext();){
FileItem fileitem =(FileItem) iter.next();
if(!fileitem.isFormField()fileitem!=null){//判读不是普通表单域即是file
操作fileitem文件步骤,可以获取大小、路径
}
}
热心网友 时间:2023-07-04 21:03
@ResponseBody
@PostMapping("/uploadFile")
public Object uploadFile( HttpServletRequest request) {
//进行分布式对象存储Ambry文件上传
MultipartHttpServletRequest req =(MultipartHttpServletRequest)request;
MultipartFile file = req.getFile("file");
}
}