Good evening I am developing an application with angularjs using rest services and perform a method to obtain a list of visits from a specific person for which I pass the ID number And I should return the list but it does not do so where is the error or what could I do to solve this? Thanks. I attach the code REST SERVICE
@RequestMapping(value = "/Visita/{chv_cedula}", method = RequestMethod.GET, produces = "application/json")
public void findVisitas(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, @PathVariable("chv_cedula") String chv_cedula) {
try {
List<Evisitas> visitas = visitasDAO.findVisitas(chv_cedula);
String jsonSalida = jsonTransformer.toJson(visitas);
httpServletResponse.setStatus(HttpServletResponse.SC_OK);
httpServletResponse.setContentType("application/json; charset=UTF-8");
httpServletResponse.getWriter().println(jsonSalida);
} catch (BussinessException ex) {
List<BussinessMessage> bussinessMessage = ex.getBussinessMessages();
String jsonSalida = jsonTransformer.toJson(bussinessMessage);
httpServletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
httpServletResponse.setContentType("application/json; charset=UTF-8");
try {
httpServletResponse.getWriter().println(jsonSalida);
} catch (IOException ex1) {
Logger.getLogger(VisitaController.class.getName()).log(Level.SEVERE, null, ex1);
}
} catch (Exception ex) {
httpServletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}}
SERVICE CONSUMPTION FROM ANGULARJS
var app = angular.module("app", ['ngRoute', 'satellizer', 'map']);
function RemoteResource($http, $q, baseUrl) {
this.listvisitam = function (chv_cedula) {
var defered = $q.defer();
var promise = defered.promise;
$http({
method: 'GET',
url: baseUrl + '/api/Visita/' + chv_cedula
}).success(function (data, status, headers, config) {
defered.resolve(data);
}).error(function (data, status, headers, config) {
if (status === 400) {
defered.reject(data);
} else {
throw new Error("Fallo obtener los datos:" + status + "\n" + data);
}
});
return promise;
};
}
ROUTEPROVIDER
$routeProvider.when('/visitas/miembro', {
templateUrl: "vistas/lstvisitasm.html",
controller: "VisitasMiembroController",
resolve: {
vmiembro: ['remoteResource', 'sesionesControl', function (remoteResource, sesionesControl) {
var chv_cedula = sesionesControl.get("chv_cedula");
return remoteResource.listvisitam(chv_cedula);
}]
}
});
CONTROLER
app.controller("VisitasMiembroController", function ($scope, vmiembro) {
$scope.vmiembro = vmiembro;
});