I'm trying to consume webservice on my local machine and use AngularJS $http. Via browser everything works fine and I receive correct JSON response.
But with AngularJS $http I receive 404 error, however, handler is found and response is being generated.
FrontEnd:
$http.get('http://localhost:8080/apartments.json').
success(function(data){
$scope.apartments = data;
}).
error(function(data, status){
alert("Error "+ status);
});
BackEnd:
@Controller
public class ApartmentsController {
@RequestMapping(value = "/apartments", method = RequestMethod.GET)
public @ResponseBody List<ApartmentEntity> getAll(){
ApartmentEntity apartmentEntity = new ApartmentEntity();
apartmentEntity.setName("test");
apartmentEntity.setPrice(1000);
return Arrays.asList(apartmentEntity);
}
}
Servlet is mapped correctly.
Could you please suggest what is wrong?
http://localhost:8080and Web application is being reached fromhttp://localhost:4040. Then you have a CORS conflict.