Results 1 to 2 of 2

Thread: problems with multipart/form-data boundary and controller

  1. #1
    Join Date
    Jun 2012
    Posts
    1

    Question problems with multipart/form-data boundary and controller

    Hello,

    I have this form:
    <form id="uploadForm" name="uploadForm" method="POST" action="/webapp/spring/upload" enctype="multipart/form-data; boundary=--------boundary123">

    My controller's method is bound like this:
    @RequestMapping(value = "/upload", method = RequestMethod.POST, headers = "content-type=multipart/form-data")

    I'm getting this error: Unsupported Media Type
    This is happening because my request type is for some reason changed to "application/x-www-form-encoded". Is my form enctype not specified correctly?

    When I change enctype to "multipart/form-data" only (no boundary) the method is called but then I get an error about a missing multipart boundary.

    Has anyone encountered that problem before? How to fix it? Ultimately I'm trying to upload a file (with apache ServletFileUpload).
    Thanks,

    M

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Try without the 'boundary=' part... That might confuse the browser (also not sure what it should do).

    And please next time use [ code][/code ] tags when posting code(snippets) ....
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

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