Angular JS $hhtp returns the status code 0 on calling the get request from the spring rest controller. The rest controller in the example below produces "application/json".
The response come fine if the URL is tested in the browser. It successfully prints the response on the chrome browser, but the same request returns the status code 0 if called from angular js $http. Below is the sample request and spring rest controller for the same.
The above angular method returns the status code 0 on calling the spring rest controller. The issue occure because of HTTP Access Control CORS issues.
Angular does not consume the response from the server that does not include Access-Control-Allow-Origin header in the response. The server responding back the angular JS calls must include the headers specified by CORS. In order to make it work, you need to include the below annotation of Spring.