java - parseRequest gives empty list in spring -
in java method saving file using apache common file upload using spring framework when try list parserequest
gives 0 size don't know why error come picture can 1 please me resolved
my code
@requestmapping(value = "/documentpdfupload", method = {requestmethod.post }) public void editedpdfupload(model model,@requestparam map<string,object> reqparams,httpservletrequest request,httpservletresponse response) throws ioexception { // initialize response response.setcontenttype("text/html;charset=utf-8"); printwriter out = response.getwriter(); // check have file upload request boolean ismultipart = servletfileupload.ismultipartcontent(request); log.debug("ismultipart"+ismultipart); if (ismultipart == false) { echomessage ("post not multipart request", out); return; } // create factory disk-based file items diskfileitemfactory factory = new diskfileitemfactory(); factory.setsizethreshold(65536); factory.setrepository(new file("c:\\temp")); system.out.println("factory=============================>"+factory); enumeration paramnames = request.getparameternames(); while(paramnames.hasmoreelements()) { string paramname = (string)paramnames.nextelement(); string[] paramvalues = request.getparametervalues(paramname); system.out.println (paramvalues); } // create new file upload handler servletfileupload upload = new servletfileupload(factory); system.out.println("upload=============================>"+upload); // parse request /* fileitem */ try { // process uploaded items list items = upload.parserequest(request); system.out.println("items size=============================>"+items.size()); iterator iter = items.iterator(); while (iter.hasnext()) { fileitem item = (fileitem) iter.next(); if (item.isformfield() == false) { string filename = item.getname(); file uploadedfile = new file("c:\\tmp\\" + filename); item.write(uploadedfile); break; } } } catch (exception e) { echomessage("error: " + e.getmessage(), out); e.printstacktrace(); } // close response writer out.close(); }
Comments
Post a Comment