Recently, when I was working on a project, I used jspsmartupload to upload files. However, I found a problem where request. getParameter ("name") could not be used to obtain the form data. Finally, I finally solved the problem and left an article.
The reason is simple:
Because the format of the post request when you use jspsmartuploadsmart is multipart/form-data, that is, enctype = "multipart/form-data", which is different from the default form submission.
The differences are mainly reflected in: the formats of the data transmitted to the server are different, that is, the protocols are different (the related format description file can be found on the 3W official website ). The current WEB Container implements the HttpServletRequest method getParameter (str) according to the default protocol. It is no wonder that the value obtained by request. getParameter () is null.
Solution:
Using smartupload, you have provided specific methods,
Common request. getParameter () is not allowed ()
You can use upload. getRequest ().
Example:
SmartUpload su = new SmartUpload ();
// Upload Initialization
Su. initialize (pageContext );
// Set upload restrictions
// 1. Limit the maximum length of each uploaded file.
// Su. setMaxFileSize (10000 );
// 2. Restrict the total length of uploaded data.
// Su. setTotalMaxFileSize (20000 );
// 3. Set the files that can be uploaded (with the extension limit). Only the doc and txt files are allowed.
// Su. setAllowedFilesList ("xml ");
// 4. Set files that are not allowed to be uploaded (restricted by the extension). Do not upload files with the exe, bat, jsp, htm, and html extensions or files without extension extensions.
// Su. setDeniedFilesList ("exe, bat, jsp, htm, html ,,");
// Upload a file
Su. upload ();
String softname = su. getRequest (). getParameter ("softname ");
Note: It must be obtained after su. upload !!
This article is from "Practice record"