Map map=NewHashMap (); BooleanIsmultipart =servletfileupload.ismultipartcontent (Request); if(Ismultipart) {//File Upload//processing with stream API for improved performance//System.err.println ("File upload request ...");Servletfileupload upload =Newservletfileupload (); Fileitemiterator Fileitemiterator=Upload.getitemiterator (Request); for(; Fileitemiterator.hasnext ();) {Fileitemstream Item=Fileitemiterator.next (); String name=Item.getfieldname (); SYSTEM.OUT.PRINTLN (name); if(Item.isformfield ()) {InputStream stream=Item.openstream (); //Normal domainString value = streams.asstring (Stream, "UTF-8"); if(Map.containskey (name)) {String Valueto=(String) map.get (name); Valueto+= "," +value; Map.put (name, Valueto); } Else{map.put (name, value); } stream.close (); } Else { //file FieldsInputStream in = Item.openstream ();//Get file Stream } } }
Java gets the fields and file streams in form forms