CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver( servletContext );
multipartResolver.setMaxUploadSize( multipartConfig.getMaxFileSize() );
multipartResolver.setMaxInMemorySize( multipartConfig.getFileSizeThreshold() );
try {
multipartResolver.setUploadTempDir( new PathResource( multipartConfig.getLocation() ) );
}
catch ( IOException ioe ) {
throw new ServletException( "Illegal location for multipart uploads: " + multipartConfig.getLocation() );
}