Commons-fileupload Upload File (1), commons. fileupload

Source: Internet
Author: User

Commons-fileupload Upload File (1), commons. fileupload

Recently, I used the commons-fileupload component to write an image upload function. Submitted form to the background (structs framework is not used here), and List pl = dfu in the background. parseRequest (request); Iterator iterator = pl. iterator (); the length of iterator is always zero. If the input parameter passed in is not of the type = file type, the request cannot be used. getParameter () is obtained. This is because the content type submitted by form is "multipart/form-data". Now we must use the parseRequest (request) method; parseRequest () the parseRequest method parses the data of fields in the form, encapsulates the data into independent fileItem objects, and adds these fileItem objects to a list-type Collection object. Then all parameters must be obtained through iterative iterator, and isFormField is used to determine whether they belong to a common form field. Here we just mentioned that the iterator length is zero because we didn't give the name attribute to the label in form, for example: <input type = "file" value = "Upload image" name = "uploadImage"/>.

Demo download: http://download.csdn.net/detail/u014458334/8895899

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.