0

I am making a call to my web service that is wired up in roo to do a put. I am using the HiddenHttpMethodFilter in order to route the call to my PUT handler on the server side. My Put method service sides looks as such.

@RequestMapping(value = "/{chainId}", method = RequestMethod.PUT, headers =     "Accept=application/json")
public ResponseEntity<String> updateUser(@PathVariable("chainId") String chainId, @RequestBody MultiValueMap<String, String> form) {
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Type", "application/json");
    headers.add("Access-Control-Allow-Origin", "*");
    Chain chain = Chain.findChain(chainId);
    GymMember gymMember = new GymMember();
    gymMember.setMembershipId(form.getFirst("membershipId"));
    gymMember.setEmail(form.getFirst("email"));
    gymMember.setEmail(form.getFirst("name"));
    gymMember.setEmail(form.getFirst("age"));
    gymMember.setEmail(form.getFirst("sex"));
    gymMember.setChainId(chain);
    if (gymMember.merge() == null) {
        return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND);
    }
    return new ResponseEntity<String>(headers, HttpStatus.OK);
}

The calls to this method are landing here but the @RequestBody MultiValueMap form always has no data. It is represented as {} when I debug and look at its contents.

My calls can be seen here

Request URL:http://localhost:9080/FitFriendsService/gymmembers/1006
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Origin:http://localhost:8888
Referer:http://localhost:8888/fitFriends/profile.html?chainId=1006&membershipId=testing&email=testing
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Form Dataview URL encoded
_method:PUT
membershipId:testing
email:testing
name:John Forgintonagwhaaa
age:33
sex:Male

I have read that you can't send form data using a put request per the HTML guidelines but I am not sure if this is correct. If you know of a way to make it so that spring roo can get that form data it would be much appreciated! Thanks!

0 Answers0