开发者

How to upload mulitpart/form-data with apache common-fileupload and Spring?

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("---"+fo开发者_如何学Gorm.getProductName());
    System.out.println("---"+form.getRfile());

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

}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜