来自jquery.ajax的Spring Roo PUT请求

时间:2012-06-13 17:18:41

标签: jquery ajax spring xmlhttprequest spring-roo

我正在打电话给我的网络服务,该网络服务是在roo中连接进行的。我正在使用HiddenHttpMethodFilter将调用路由到服务器端的PUT处理程序。我的Put方法服务方面看起来就像这样。

@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);
}

此方法的调用在此处着陆,但@RequestBody MultiValueMap表单始终没有数据。当我调试并查看其内容时,它表示为{}。

我的电话可以在这里看到

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

我已经读过你不能按照HTML指南使用put请求发送表单数据,但我不确定这是否正确。如果您知道如何制作它以便spring roo可以获得该表单数据,那将非常感激!谢谢!

0 个答案:

没有答案