-1

I am trying to upload files with apache common-fileupload and spring, and my form contains fields also. but when i am trying to submit always getting null pointer exception

so now using Multipartstream for getting solution on the same.

@RequestMapping(value="/uploadfile.do", method = RequestMethod.POST)
public ModelAndView uploadFile(@ModelAttribute("frm") ReceiptForm form, BindingResult result, HttpServletRequest request){

    System.out.println("---"+form.getProductName());
    System.out.println("---"+form.getRfile());

    ModelAndView mav = new ModelAndView("receipt/upload");
    mav.addObject("command", form);
    return mav;

}
skaffman
  • 398,947
  • 96
  • 818
  • 769
Vinod Puliyadi
  • 225
  • 1
  • 3
  • 14
  • the spring MVC official documentation has examples of that. Didn't it work for you? – Bozho Mar 11 '11 at 11:40
  • Have you tried it by yourself? Have you checked some docs? Have you written some piece of code at which you're stuck now? Or are you simply asking for somebody to do your job for free? – Tomas Narros Mar 11 '11 at 11:43
  • i tried but always i am getting null pointer exception, so now i am trying using MultipartStream – Vinod Puliyadi Mar 11 '11 at 11:55
  • 2
    Some extracts of significative code would be helpful to find out what's producing this behaviour. – Tomas Narros Mar 11 '11 at 11:59

1 Answers1

1

The following example shows how to use the CommonsMultipartResolver:

<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

<!-- one of the properties available; the maximum file size in bytes -->
<property name="maxUploadSize" value="100000"/>

By adding this to your spring config your controllers should pickup file uploads

or try google

Mark Bakker
  • 1,278
  • 8
  • 19