0

I'm trying to send a RESTful request to my java web app hosted on cloudbees.
I'm using jQuery like so:

    $.ajax({
          url: '/api/users/',
          type: 'PUT',
              dataType: 'json',
              data: {
                fbId:       facebookUserId == null ? '' : facebookUserId,
                fbName:     facebookUserName,
                lnId:       linkedInUserId == null ? '' : linkedInUserId,
                lnName:     linkedInUserName
              },
          success: function(response) { 
              internalGetConfiguration();
          }
    });

Using PUT (as in the code snippet above) causes tomcat to not pass through the parameters (fbId etc. don't get parsed or never arrive, I don't know, but I can see that they are sent). If I change to POST it goes through just fine.

Is is not possible to use PUT/DELETE with Cloudbees hosting?? is there some configuration that I need to add in order for it to work, or do I need to format it somehow?

I've seen another post regarding google app engine that it also has this issue (or at least HAD), is this a known issue at cloudbees?

4

1 回答 1

0

According to this thread on the Tomcat user group, Tomcat's implementation of the getParameter family of utility methods only supports auto-parsing of a x-www-form-urlencoded content body for POST/GET requests. The behavior is not nailed down by the Servlet spec, so may vary between Servlet engines. In REST semantics, PUT requests are generally meant to be a way to replace the content of the resource, so being conservative about auto-manipulating the content body doesn't seem inappropriate.

To ensure that your code works across all Java EE deployment environments, your best bet is to directly parse the content body of the HTTP request from inside your application. The Apache HttpComponents library has some functionality for parsing form encoded content that may help.

于 2012-09-11T16:00:33.133 回答