一起学习网 一起学习网

java request方式上传文件获取form-data其它字段值

RequestContext requestContext = new ServletRequestContext(request);
boolean isMultipart = FileUpload.isMultipartContent(requestContext);

DiskFileItemFactory factory = DiskFileItemFactory();
ServletFileUpload upload = ServletFileUpload(factory);
//获得表单提交de对象,itemList就是所有字段集合,可以循环获取
List<FileItem> itemList = upload.parseRequest(request); FileItem item = itemList.get(0); //某个字段的值 log.info("uuid="+itemList.get(1).getString());