Q: Cannot get file object and file name in struts background?
Answer: 1. To Dropzone.js search "return xhr.send (formData);"
2. There is a code in front of it:
for (i = _m = 0, _ref5 = files.length-1; 0 <= _ref5? _m <= _ref5: _m >= _ref5; i = 0 <= _ref5? ++_m:--_ m) { formdata.append (this. _getparamname (i), files[i], files[i].name); }
3. Locate the code and change the Formdata.append (...) to the following:
for (i = _m = 0, _ref5 = files.length-1; 0 <= _ref5? _m <= _ref5: _m >= _ref5; i = 0 <= _ref5? ++_m:--_ m) { formdata.append ("Files", Files[i], files[i].name); Formdata.append ("FileNames", Files[i].name); }
4. Then define the global files,filenames in Java to provide a get, set method to get the file object and name, as follows:
Privatefile[] files;//uploaded Files PrivateString[] FileNames;//file name Publicfile[] GetFiles () {returnfiles; } Public voidsetfiles (file[] files) { This. Files =files; } Publicstring[] GetFileNames () {returnFileNames; } Public voidsetfilenames (string[] fileNames) { This. FileNames =FileNames; }
5. OK, you can test in your method to see if the object has been acquired?
Note: The other configuration information about uploading files is the same as the struts normal upload configuration can be!
Dropzone Development Related reference:
http://www.tuicool.com/articles/AZfE7v
Struts integrated dropzone.js upload pictures encountered point problems