I'm hoping a member can help me.
I am using the Spring Framework (in particular their Web MVC annotations) for an application I am working on but I've hit a bit of a snag.
I have an annotated controller which uses a form backing object that contains (amongst other things) a MultipartFile.
When I submit the form if I choose a file and then submit the code works fine. However if I don't choose a file and submit the form I get the following error:
This is obviously a binding error. Does anyone know why it would be attempting the bind a string even if the item is empty?
Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.MultipartFile] for property 'imageFile'
One thing I have tried is to edit the binder by doing the following:
But it seems to still attempt to bind the file?
public void initBinder(WebDataBinder binder)
I've done a search of the forums but cannot seem to find anyone with the same error?
For reference the command object behind my form is like this:
Also as a side note I have tested the functionality with a non annotated controller (so url mappings and definition in the servlet.xml) and this seemed to work fine but I would much rather use annotations? And you guys probably know that when something isn't working it bugs you until you find out why
public class CategoryCommand
private MultipartFile imageFile=null;
* @return the imageFile
public MultipartFile getImageFile()
* @param imageFile the imageFile to set
public void setImageFile(MultipartFile imageFile)
this.imageFile = imageFile;
Any help would be much appreciated?!?