【发布时间】:2016-11-27 17:39:17
【问题描述】:
我正在发出如下的 POST 请求:
$.ajax({
url :"/clientCredentials.json",
type: "POST",
data: {
"clientEmail": email,
"clientName":clientName,
"orgName":orgName,
"logoURL":logoURL,
"redirectURI":redirectUri
},
success: function(response){
alert("sucess");
},
error:function(response){
alert("something went wrong");
}
});
在服务器上,我使用@RequestParams 来获取这些数据。
@RequestParam String clientEmail, @RequestParam String clientName, @RequestParam String orgName, @RequestParam String logoURL, @RequestParam String redirectURI
我从服务器获取以下信息:
{"code":"400","errorMessage":"Required String parameter 'clientEmail' is not present"}
如果我使用@RequestBody 而不是@RequestParam 来接受这些数据,它工作正常。
我的问题是如何在请求参数中获取这些数据?我究竟做错了什么? 我也试过 Jquery($.get(), $.post()) 。没有任何工作。
感谢您的帮助。
【问题讨论】:
-
您可以在浏览器开发者工具中看到它。在 chrome 上,这是在网络选项卡下。关于 spring 和 @RequestParams,我无法帮助你,但 jquery。
-
谢谢,@Loenix。我得到了它。我的服务器配置有问题。
标签: javascript jquery ajax spring spring-annotations