I am currently facing an issue while trying to load my table from a JSON response that I receive from REST web services in SpringMVC. The error message I received indicates that my REST method does not support the GET request.
The URL mapped in my controller is:
http://localhost:8080/MyApp/doc/showDocTable/
However, the URL changes unexpectedly to:
http://localhost:8080/MyApp/doc/showDocTable/?count=10&page=1
This change in URL format is puzzling as I am following a basic example from this website
Here is the function within my controller responsible for calling the web services:
var Api = $resource('http://localhost:8080/MyApp/doc/showDocTable/');
this.tableParams = new NgTableParams({}, {
getData: function (params) {
// ajax request to api
return Api.get(params.url()).$promise.then(function (data) {
params.total(data.inlineCount); // recal. page nav controls
return data.results;
});
}
});
Additionally, here is the relevant controller method in Spring MVC:
... ...Any idea what could be causing this unusual URL transformation and subsequently leading to the error?
EDIT 1 I made some modifications to both the backend URL configuration and the AngularJS controller method URL as mentioned below:
@RequestMapping(value = "/doc/showDocTable", method = RequestMethod.GET)
public ResponseEntity<List<HistDoc>> showTable() {
List<HistDoc> listHistDoc = docDAO.getDocs();
return new ResponseEntity<List<HistDoc>>(listHistDoc, HttpStatus.OK);
}
var Api = $resource('http://localhost:8080/MyApp/doc/showDocTable');
However, these changes resulted in a new error appearing in the browser console:
Error: $resource:badcfg
Response does not match configured parameter
...
EDIT 2: Included below is the HTML snippet along with the JSON data returned from the backend:
... ...