Oct 26th, 2012, 03:01 AM
How do I display validation errors about an uploaded multipart file using Spring MVC
I have a Spring MVC application with a file upload form.
I would like to be able to display validation errors to a user if the uploaded content is not valid (e.g. the content is not an image, etc.)
However, by definition what is posted is of type: MultipartFile (multipart/form-data) and therefore I can't have a @ModelAttribute in my form and in order to use a BindingResult, it seems I do need a @ModelAttribute just before the BindingResult.
My question is then, what is the most appropriate way of displaying validation errors to a user when all I have is a MultipartFile? I could of course manually add model attributes to the model but I am sure there is a better way.
Thanks in advance,