Have a controller method that has a @RequestParam MultipartFile[]
parameter along with other parameters.
When using spring boot 2.2.0.RELEASE with spring-web 5.2.0, if I send a request to this endpoint without the multipart file attachment, it gives no issue and the request is accepted as exepected.
After updating to spring boot 2.7.5 with spring-web 5.3.23 sending the same request to the endpoint i.e. without any multipart file attachment gives the following error:
org.springframework.web.multipart.support.MissingServletRequestPartException [Required request part 'files' is not present]
Comment From: rstoyanchev
I haven't narrowed down to a specific change responsible for this, and I understand that it represents a change of behavior. However, the default value for RequestParam#required
is true
, which makes the current behavior closer to what I would expect. Have you tried with required=false
?
Comment From: lathutkarsh
Yes, tried required=false and it does solve the issue. Just wanted to understand how or when the change in behavior happened as I couldn't find any documentation regarding the same
Comment From: rstoyanchev
This related to the changes for #25819 made for 5.3. Again, I understand this is a change of behavior, but as the current behavior is correct, we are going to leave it that way.