I'm trying to post data from Angular to my servlet. But, it throws me the error
"Failed to load resource: the server responded with a status of 405 (Method Not Allowed)"
Here is my code. Am I missing anything?
$scope.pushDataToServer = function() {
$scope.data = {user_id:"123",key_name:"key2",value:"value2"};
$http({
method: 'POST',
url: 'pushData',
headers: {'Content-Type': 'application/json'},
data: $scope.data
}).success(function (data){
$scope.status=data;
}).error(function(data, status, headers, config) {
alert("error")
});
};
My servlet config
<servlet>
<servlet-name>pushData</servlet-name>
<servlet-class>com.data.pushData</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>pushData</servlet-name>
<url-pattern>/pushData</url-pattern>
</servlet-mapping>