首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

common-fileupload文件下传 表单值参数取值

2012-10-28 
common-fileupload文件上传 表单值参数取值用JSPSmartUpload或common-fileupload来做直接用request.getPar

common-fileupload文件上传 表单值参数取值

用JSPSmartUpload或common-fileupload来做


直接用request.getParameter( "name "); ? 是取不到值的

?

因为JSPSmartUpload或common-fileupload又将参数值进行了一次封装,所以,直接取是没法取到的。

?

SmartUpload?取表单值值方法:

SmartUpload ? mySmartUpload ? = ? new ? SmartUpload();

if (FileUpload.isMultipartContent(requestContext)) { DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setRepository(new File(savaFilePath)); ServletFileUpload upload = new ServletFileUpload(factory); // upload.setHeaderEncoding("gbk");50MB bytes upload.setSizeMax(51200000); List items = new ArrayList(); try { items = upload.parseRequest(request); } catch (FileUploadException e1) { System.out.println("文件上传发生错误" + e1.getMessage()); } Iterator it = items.iterator(); while (it.hasNext()) { FileItem fileItem = (FileItem) it.next(); if (fileItem.isFormField()) { uploadResult="0";// String name = fileItem.getFieldName(); // if (fileItem.getFieldName().equals("username")){ // System.out.println("fileItem.toString() "+fileItem.toString()+" "+fileItem.getString());// } username=new String(fileItem.getString().getBytes( "iso8859-1"), "gbk");// System.out.println(fileItem.getFieldName()// + " 00 "// + fileItem.getName()// + " 01 "// + new String(fileItem.getString().getBytes(// "iso8859-1"), "gbk")); }

?

?

热点排行