我一直收到HTTP错误请求,但我不确定原因。下面是产生错误的代码:
$http(
{
method : 'POST',
url : 'http://localhost:8081/spring/employee-module/searchvalue',
data : $scope.idNumber,
headers : {
'Content-Type' : 'application/x-www-form-urlencoded'
}
}).then(function(response) {
return response.data;
});
答案 0 :(得分:0)
您的javascript格式不正确。试试这个:
$http.post('http://localhost:8081/spring/employee-module/searchvalue', {
data: $scope.idNumber,
headers: {
//did you mean x-www-form-urlencoded??
'ContentType': 'application/json; charset=utf-8'
}
}).then(function(response) {
return response.data;
}, function(error) {
//error
});