Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-5628

Support for PUTting form-encoded data


    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 3.0 M3
    • Fix Version/s: 3.1 RC1
    • Component/s: Web
    • Labels:
    • Last commented by a User:


      In RESTful services scenario it is not uncommon to accept the incoming data (as service input) in the form-encoded format (Content-type: application/x-www-form-urlencoded). This format is well-known, popular, implemented in every language. See the RESTful Web Service book from O'Reilly for longer discussion of such choice.
      Obviously, REST service will accept form-endoded data in POST and PUT request. The problem is that servlet spec (or implementations) seems to be broken in this area. HttpServletRequest.getParameter("foo") method for form-encoded data returns the parameter value only for POST requests, not for PUT. I've tested it on Tomcat and Glassfish.
      This also means that all Spring's autobinding features (with command object) will fail for PUT requests. This is really serious problem, as for PUT requests, one have to manually parse and decode the request body.
      The solution would be I think to add some filter, which wraps the request when the method is PUT and content type is "application/x-www-form-urlencoded", and override the getParameter() and related methods.
      It would be probably also helpful to check the servlet spec for explanation of this behavior, and how it is implemented in Tomcat (or other containers).

      To reproduce, simply create servlet or JSP like this:
      and send POST and then PUT request to it, with content-type set to "application/x-www-form-urlencoded" and body equal to "foo=bar"


          Issue Links



              • Assignee:
                rstoya05-aop Rossen Stoyanchev
                grzegorzborkowski Grzegorz Borkowski
                Last updater:
                Rossen Stoyanchev
              • Votes:
                4 Vote for this issue
                7 Start watching this issue


                • Created:
                  Days since last comment:
                  5 years, 14 weeks, 4 days ago