Enabling file uploads in Spring MVC requires configuring a multipart resolver to parse multipart request bodies, along with matching form and size settings so uploads are accepted and safely bounded.
Key Points: • A MultipartResolver bean must be registered; StandardServletMultipartResolver works on Servlet 3.0+ containers without extra libraries. • Spring Boot applications typically don't need a manual bean — multipart support is auto-configured and controlled via application properties instead. • The HTML form must declare enctype="multipart/form-data" for the browser to actually send the file as part of the request body. • spring.servlet.multipart.max-file-size and spring.servlet.multipart.max-request-size cap individual file size and total request size respectively. • spring.servlet.multipart.enabled (true by default in Boot) can be toggled off if multipart handling isn't wanted for some reason.
Example: A Spring Boot app just needs application.properties entries for the size limits since multipart handling is on by default, whereas a plain Spring MVC app configured via XML or Java config needs to explicitly declare the StandardServletMultipartResolver bean.
Code Example:
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=15MBInterview Tip: A concise interview answer is:
"I need a MultipartResolver bean — StandardServletMultipartResolver on Servlet 3.0+ — though Spring Boot auto-configures this already. On top of that the form needs multipart/form-data encoding, and I set max-file-size and max-request-size properties to bound how much data the server will accept."