`
zoutuo1986
  • 浏览: 178955 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论

带文件form提交后台

    博客分类:
  • code
阅读更多
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);
						
					}
				}
			} 

 

分享到:
评论
Global site tag (gtag.js) - Google Analytics