FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List<FileItem> items = null; SignatureBean bean = SignatureFactory.getInstance().getBean(); items = upload.parseRequest(request); for (FileItem item : items) { if(!item.isFormField()){ String name = new String(item.getFieldName().getBytes("ISO-8859-1"),"UTF-8"); String fileFullName = new String(item.getName().getBytes("ISO-8859-1"),"UTF-8"); if("markfile".equals(name)){ bean.setBody(item.getInputStream()); bean.setMarktype(FileUtils.getFiletype(fileFullName)); } }else{ String name = new String(item.getFieldName().getBytes("ISO-8859-1"),"UTF-8"); String val = new String(item.getString().getBytes("ISO-8859-1"),"UTF-8"); if("markname".equals(name)){ bean.setMarkname(val); } if("password".equals(name)){ bean.setPassword(val); } if("signatureid".equals(name)){ bean.setSignatureid(val); } if("use_user_id".equals(name)){ bean.setUse_user_id(val); UserCacheBean user = UserCache.getUserCacheBean(val); bean.setUse_unit_id(user.getUnit_id()); bean.setUse_unit_name(user.getUnit_name()); } if("username".equals(name)){ bean.setUsername(val); bean.setUse_user_name(val); } } }
评论