及彼参数为Null是控制器Angularjs弹簧:在控制器
@RequestMapping(value = "/fetchRecord/", method = RequestMethod.POST)
@ResponseBody
public String fetchRecord(Integer primaryKey)
{
return this.serviceClass.fetchRecord(primaryKey);
}
代码这里是我的角码
var dataObj = {
primaryKey : $scope.primaryKey
};
var res = $http.post('/Practice/learn/fetchRecord/', dataObj);
res.success(function(data, status, headers, config) {
$scope.firstname = data;
});
res.error(function(data, status, headers, config) {
alert("failure message: " + JSON.stringify({
data : data
}));
});
我能够调试我的代码。虽然我可以在浏览器中检查它的值是否通过了primaryKey。但控制器仍然是空的。
有什么可能的原因吗?
您可能会尝试fetchrecord(@Requestbody Integer primkey) –
面临错误:客户端发送的请求在语法上不正确。 – sparsh610
而$ http.put而不是后 –