Jspsmartupload File Uploading servlet does not get jsp Parameters

Source: Internet
Author: User

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"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.