Hi there,
I've tried to get the automagical conversion of upload file contents to a string by doing this in my MultiActionController:
but it wouldn't work, gave me a conversion error. Is there a reason why the multiaction controller can't support this?Code:protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws ServletException { binder.registerCustomEditor(String.class, new StringMultipartFileEditor()); }
I implemented the following:
and then use the three parameter version of my request method:Code:public class UploadBean { private org.springframework.web.multipart.commons.CommonsMultipartFile uploadFileContents; public org.springframework.web.multipart.commons.CommonsMultipartFile getUploadFileContents() { return uploadFileContents; } public void setUploadFileContents(org.springframework.web.multipart.commons.CommonsMultipartFile uploadFileContents) { this.uploadFileContents = uploadFileContents; } }
and then use the following to get my string:Code:public ModelAndView saveAndValidate(HttpServletRequest request, HttpServletResponse response, UploadBean ub) throws Exception {
I present this as a working solution for the multiaction controller, but if anyone could tell me why this wasn't built in or if there is a problem that I'm not aware of that would be great.Code:new String(ub.getUploadFileContents().getBytes());
Thanks in advance,
Mark


Reply With Quote