使用Spring MVC 3的错误请求(404)

时间:2016-04-27 17:46:55

标签: angularjs spring-mvc

我一直收到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;
    });

1 个答案:

答案 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
});