I have not had the pleasure of upgrading to Spring 3.X yet.
There is some excellent documentation on File Upload with Spring.
However for an annotation driven Controller it misses out one important step, namely the @InitBinder annotation.
@InitBinder
public void initBinder(ServletRequestDataBinder aBinder) throws ServletException {
// to actually be able to convert Multipart instance to a String
// we have to register a custom editor
aBinder.registerCustomEditor(String.class, new StringMultipartFileEditor());
// now Spring knows how to handle multipart object and convert them
}
No comments:
Post a Comment