common:parseMultipart

This tag can handle file upload posts. That is – if such a post is done this tag is needed if you wish to extract both normal parameters and files – the normal http-request object will not do that for you.

Parameters

Name Required Default Type Description
id false   String The result is stored in this variable.
maxSize true   Object/String Sets how large file are allowed.
allowedContentTypes false   Object/String Sets which content types are allowed. Comma seperated string.
ignoreEmpty false   Object/String Sets if the file can be left out.
         

ID-result variable contains:
A java.util.Map-object containing all post information.

Examples

This example parses a form-post including files but only allows files are no bigger than 100.000 bytes and of content type gif, jpg or png. It then gets a form parameter we know are sent in and lists all files posted.

<common:parseMultipart id="formParameters" maxSize="100000" allowedContentTypes="image/gif,image/jpg,image/png" ignoreEmpty="true"/>
The form contained the field company name and the value filled in was: <c:out value="${formParameters.companyName}"/>
<c:forEach var="fileItem" items="${formParameters.files}">
Uploaded file: <c:out value="${fileItem.name}"/> had content type
<c:out value="${fileItem.contentType}"/>
</c:forEach>



comments powered by Disqus