![]() |
|
Version: 0.27 - Last update: 2004-05-30 | Home Page - SourceForge Project Page - Contact |
Jodd Overview News Download License References Development Using Jodd Javadoc JUnit report Community Contribute Report a bug More reading Milestone 0.30 ![]() ![]() |
UploadMultipartRequest class handles multipart requests, i.e. file uploads.
It reads http multipart request and extract both files and parameters.Usage is simple as it can get: just create a new instance of MultipartRequest by passing current http request to its constructor:
and that's it!!! From here, a MultipartRequest object may return
either parameter values either uploaded files in a similar way as it would
be done for HttpServletRequest object. Here are some code snippets
examples:
An UploadedFile object holds data about the uploaded file and may be used for
retrieving various information about the uploaded content, as well as files raw data.
Moreover, it contains a method for storing uploaded file data directly to a file.
Non-multipart requestsMultipartRequest can also handle common, non-multipart http requests.
In this case, MultipartRequest object will hold information only for
parameter values, naturally.
Form bean mappingMultipartRequest object may be used in the very same way as
HttpServletRequest to load data from request and to populate some form bean,
by using jodd.bean.BeanUtil.load() method. As it is desribed
here, it is very easy to load from multipart request and
to populate form bean:
And that is all! Now all request parameters will be populated into the bean. Uploaded files may be populated only into the properties of UploadedFile
type.
Using encodingMultipartRequest also can handle multipart forms that uses specific
character encoding. Here is the example of the HTML form definition in this case:
Next is the example of creating multipart request that supports encoding:
Everything else stays the same. |