Results 1 to 3 of 3

Thread: command object is coming null when i am using multipart resolver for file uploading

  1. #1

    Default command object is coming null when i am using multipart resolver for file uploading

    this the code that i am writing in my application context(xyz-servlet.xml)
    <bean id="multipartresolver"
    class="org.springframework.web.multipart.commons.C ommonsMultipartResolver"><!--
    one of the properties available; the maximum file size in bytes
    --><property name="maxUploadSize" value="1000" />
    </bean>

    controller part---simple form controller
    public class RelReqExcelApprovalController extends SimpleFormController{

    public RelReqExcelApprovalController(){
    setCommandClass(FileUploadBean.class);
    setCommandName("FileUploadBean");
    }
    protected ModelAndView onSubmit(
    HttpServletRequest request,
    HttpServletResponse response,
    Object command,
    BindException errors) throws ServletException, IOException {
    FileUploadBean bean = (FileUploadBean) command;
    MultipartFile file = bean.getFile();
    System.out.println("bean file//////////"+file);//this is coming null
    }
    }

    // my form bean class
    public class FileUploadBean {

    private MultipartFile file;

    public void setFile(MultipartFile file) {
    this.file = file;
    }

    public MultipartFile getFile() {
    return file;
    }
    }
    this is all i am doing but mycommand object is coming null.

  2. #2
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Have you added enctype="multipart/form-data" to your form?

    Jörg

  3. #3

    Default

    yes i have added.....it seems to be that its not actually the problem of multipart resolver even if i am trying to fetch string feild than also it is coming null

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •