Announcement Announcement Module
Collapse
No announcement yet.
MultipartFile is null when uploading a file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MultipartFile is null when uploading a file

    Hello everyone, I've been following this tutorial, but I can't get it working...

    I have this jspx:

    Code:
    <form:deploy multipart="true" id="fc_..." modelAttribute="jrpmapplication" path="/jrpmapplications/fileupload" z="user-managed">
    		<field:input id="c_..." field="name" z="user-managed"/>
            <field:input id="c_..." field="ip" z="user-managed"/>
            <field:input id="c_..." field="port" z="user-managed"/>
            <field:input id="c_..." field="content" required="true" type="file" z="user-managed"/>
        </form:deploy>
    And this controller:

    Code:
    @RequestMapping(value = "/fileupload", produces = "text/html")
    	public String fileUpload(@RequestParam(value = "ip", required = false) String ip, @RequestParam(value = "port", required = false) BigDecimal port, @RequestParam(value = "name", required = false) String name, @RequestParam(value = "content", required = false) MultipartFile content, Model uiModel) {
    Basically I only removed BindingResult bindingResult from the controller signature, cause if I put it it'd complain that it has to go right after the model (unlike that example in which it's before it, but even if i put it after it it complains anyways).

    While the first tree parameters are ok, content is null...

    What am I missing?

    Thanks a lot everyone!!

    EDIT: this is the request payload:

    Code:
    ------WebKitFormBoundaryaacMS0A1FSJrMgtu
    Content-Disposition: form-data; name="name"
    
    dataminer
    ------WebKitFormBoundaryaacMS0A1FSJrMgtu
    Content-Disposition: form-data; name="ip"
    
    10.....
    ------WebKitFormBoundaryaacMS0A1FSJrMgtu
    Content-Disposition: form-data; name="port"
    
    8019
    ------WebKitFormBoundaryaacMS0A1FSJrMgtu
    Content-Disposition: form-data; name="content"; filename="fifthstep.xlsx"
    Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    
    
    ------WebKitFormBoundaryaacMS0A1FSJrMgtu--
    Last edited by tylerdurden83; Jul 3rd, 2013, 08:38 AM.

  • #2
    You can try the following one instead at http://viralpatel.net/blogs/spring-r...-roo-tutorial/.

    It works for sure!.
    jD

    Comment


    • #3
      Originally posted by delgad9 View Post
      You can try the following one instead at http://viralpatel.net/blogs/spring-r...-roo-tutorial/.

      It works for sure!.
      jD
      First of all thank you for the help!
      I had already managed to solve the issue sadly, and I admit that I forgot to post here my solution (which I'd have got to if I used your tutorial from the start).

      In my case, commenting:

      <bean id="multipartFilter" class="org.springframework.web.multipart.support.M ultipartFilter">
      <property name="multipartResolverBeanName" value="multipartResolver" />
      </bean>
      from the application-context.xml solved the null issue. I'm not sure what that does, but I see it's not present in the tutorial that you linked, so it's probably safe to have it removed as I did!

      Comment

      Working...
      X