To quote from API docs StandardServletMultipartResolver
does not support temporary file configuration on resolver level rather it is to be done on servlet registration level -
In order to use Servlet 3.0 based multipart parsing, you need to mark the affected servlet with a "multipart-config" section in web.xml
, or with a MultipartConfigElement
in programmatic servlet registration, or (in case of a custom servlet class) possibly with a MultipartConfig
annotation on your servlet class.
Configuration settings such as maximum sizes or storage locations need to be applied at that servlet registration level; Servlet 3.0 does not allow for them to be set at the MultipartResolver
level.
So either you can configure it on servlet or switch to CommonsMultipartResolver
which has the support to set the temp directory out-of-the-box as it inherits it from CommonsFileUploadSupport.setUploadTempDir
(see respective docs here and here)