protected MultiList<FormItem> multipartFormItems(String encoding) {

        if (!context.isRequestMultiPart())
            throw new MediaTypeException("this is not a multipart request, be sure to add this attribute to the form: ... enctype=\"multipart/form-data\" ...");

        MultiList<FormItem> parts = new MultiList<>();
        try {
            context.parseRequestMultiPartItems(encoding)
                .ifPresent(items -> {
                    for (FormItem item : items) {
                        parts.put(item.getFieldName(), item);
                    }
                });
        } catch (Exception e) {
            e.printStackTrace();
            throw new ControllerException(e);
        }
        return parts;
    }
protected MultiList < FormItem > multipartFormItems ( String encoding ) { if ( ! context . isRequestMultiPart ( ) ) throw new MediaTypeException ( "this is not a multipart request, be sure to add this attribute to the form: ... enctype=\"multipart/form-data\" ..." ) ; MultiList < FormItem > parts = new MultiList < > ( ) ; try { context . parseRequestMultiPartItems ( encoding ) . ifPresent ( items -> { for ( FormItem item : items ) { parts . put ( item . getFieldName ( ) , item ) ; } } ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; throw new ControllerException ( e ) ; } return parts ; }
Returns a collection of uploaded files and form fields from a multi-part request.
This method uses <a href="http://commons.apache.org/proper/commons-fileupload/apidocs/org/apache/commons/fileupload/disk/DiskFileItemFactory.html">DiskFileItemFactory</a>.
As a result, it is recommended to add the following to your web.xml file:

<pre>
&lt;listener&gt;
&lt;listener-class&gt;
org.apache.commons.fileupload.servlet.FileCleanerCleanup
&lt;/listener-class&gt;
&lt;/listener&gt;
</pre>

For more information, see: <a href="http://commons.apache.org/proper/commons-fileupload/using.html">Using FileUpload</a>

The size of upload defaults to max of 20mb. Files greater than that will be rejected. If you want to accept files
smaller of larger, create a file called <code>activeweb.properties</code>, add it to your classpath and
place this property to the file:

<pre>
#max upload size
maxUploadSize = 20000000
</pre>

MTD: changed to Map&lt;String, List&lt;FormItem&gt;&gt; instead of Map&lt;String, FormItem&gt;

@param encoding specifies the character encoding to be used when reading the headers of individual part.
When not specified, or null, the request encoding is used. If that is also not specified, or null,
the platform default encoding is used.

@return a collection of uploaded files from a multi-part request.