PDA

View Full Version : Can MultiActionController support CommonsMultipartResolver?


neketsushonen
May 31st, 2006, 03:37 PM
Hello Every Body:

Does any one have some experience about the use of MultiActionController with CommonsMultipartResolver?

¿That is possible to do?

Mark Fisher
May 31st, 2006, 04:10 PM
As long as a multipartResolver bean is defined in its WebApplicationContext, the DispatcherServlet will use it. Therefore the presence of an uploaded file will automatically cause the HttpServletRequest to be wrapped as a MultipartHttpServletRequest. In the controller (any controller implementation), you can check if the request is an instanceof MultipartHttpServletRequest, then cast to it and access the MultipartFile object.

A configuration example and more thorough explanation are available here (also includes binding examples with a custom editor when using a form controller): http://static.springframework.org/spring/docs/1.2.x/reference/mvc.html#mvc-multipart